BSO90

Untitled

Aug 5th, 2021
1,007
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using TaskManegementSystemCore;
  5. using TaskManegementSystemOperations.Commands;
  6. using System.Linq;
  7. using TaskManegementSystemModels.Interfaces;
  8.  
  9. namespace TaskManegementSystemOperations
  10. {
  11.     public class Add_Person_To_Team : ICommand
  12.     {
  13.         private readonly Factory factory;
  14.         private readonly Repository repository;
  15.         public Add_Person_To_Team(Factory factory, Repository repository)
  16.         {
  17.             this.factory = factory;
  18.             this.repository = repository;
  19.         }
  20.         public string Execute(IList<string> parameters)
  21.         {
  22.             string personName = parameters[0];
  23.             string teamName = parameters[0];
  24.  
  25.             return AddPersonToTeam(personName, teamName);
  26.         }
  27.         public string AddPersonToTeam(string personName, string teamName)
  28.         {
  29.             ITeam team = repository.Teams.FirstOrDefault(x => x.Name == teamName);
  30.             IMember member = repository.People.FirstOrDefault(x => x.Name == personName);
  31.  
  32.             team.CheckIfPersonIsTeamMember(personName);
  33.             team.TeamMembers.Add(personName);
  34.             team.Members.Add(member);
  35.  
  36.  
  37.             return $"{personName} added to {teamName}";
  38.         }
  39.     }
  40. }
  41.  
RAW Paste Data