Advertisement
BSO90

Untitled

Aug 6th, 2021
1,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 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_People : ICommand
  11.     {
  12.         private readonly Repository repository;
  13.         public Show_All_People(Repository repository)
  14.         {
  15.             this.repository = repository;
  16.         }
  17.         public string Execute(IList<string> parameters)//do we need iCommand here?
  18.         {
  19.             return ShowAllPeople();
  20.         }
  21.  
  22.         public string ShowAllPeople()
  23.         {
  24.             if (repository.People.Count == 0)
  25.             {
  26.                 return "There are no people created!";
  27.             }
  28.  
  29.             StringBuilder str = new StringBuilder();
  30.             int count = 1;
  31.             foreach (IMember person in repository.People)
  32.             {
  33.                 str.AppendLine($"{count++}. {person.Name}");
  34.             }
  35.  
  36.             return str.ToString().Trim();
  37.         }
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement