Advertisement
BSO90

Untitled

Aug 6th, 2021
1,342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using TaskManegementSystemOperations.Commands;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using TaskManegementSystemCore;
  6. using TaskManegementSystemModels.Interfaces;
  7.  
  8. namespace TaskManegementSystemOperations
  9. {
  10.     public class Show_All_Teams : ICommand
  11.     {
  12.         private readonly Repository repository;
  13.         public Show_All_Teams(Repository repository)
  14.         {
  15.             this.repository = repository;
  16.         }
  17.         public string Execute(IList<string> parameters)
  18.         {
  19.             if (parameters.Count != 0)
  20.             {
  21.                 throw new ArgumentException("Please write only the command!");
  22.             }
  23.             return ShowAllTeams();
  24.         }
  25.  
  26.         public string ShowAllTeams()
  27.         {
  28.             StringBuilder str = new StringBuilder();
  29.             foreach (ITeam team in repository.Teams)
  30.             {
  31.                 int count = 1;
  32.                 str.AppendLine($"{count++}. {team.Name}");
  33.             }
  34.  
  35.             return str.ToString().Trim();
  36.         }
  37.      }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement