SHARE
TWEET

Untitled

a guest Feb 18th, 2020 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using Project01.Factory;
  2. using Project01.Models;
  3. using Project01.Models.TeamItems;
  4. using Project01.Models.WorkItems.Contracts;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9.  
  10. namespace WorkItemManagementSystem.DataBase
  11. {
  12.    public  class DataBase
  13.     {
  14.         private  readonly ICollection<Team> teams;
  15.         private readonly ICollection<Member> workers;
  16.         private readonly ICollection<IFSBWorkItem> workItems;            
  17.  
  18.         private DataBase()
  19.         {
  20.             teams = new List<Team>();
  21.             workers = new List<Member>();
  22.             workItems = new List<IFSBWorkItem>();
  23.         }
  24.         public void AddMember(Member memberToCreate)
  25.         {
  26.             workers.Add(memberToCreate);
  27.         }
  28.         public void AddTeam(Team teamToCreate)
  29.         {
  30.             teams.Add(teamToCreate);
  31.         }
  32.         public bool DeleteContact(Member memberToDelete)
  33.         {
  34.             var deleteW = FindMember(memberToDelete);
  35.             if (deleteW==null)
  36.             {
  37.                 return false;
  38.             }
  39.             workers.Remove(deleteW);
  40.             return true;
  41.         }
  42.         public bool DeleteTean(Team teamToDelete)
  43.         {
  44.             var deleteT = FindTeam(teamToDelete);
  45.             if (deleteT == null)
  46.             {
  47.                 return false;
  48.             }
  49.             teams.Remove(deleteT);
  50.             return true;
  51.         }
  52.         public Member FindMember(Member memberToUpdate)
  53.         {
  54.             var member = workers.FirstOrDefault(m => m.Name.Equals(memberToUpdate.Name));
  55.             return member;
  56.         }
  57.         public Team FindTeam(Team teamToUpdate)
  58.         {
  59.             return teams.FirstOrDefault(m => m.Name.Equals(teamToUpdate.Name));
  60.         }
  61.         public bool IsMemberIn(string name)
  62.         {
  63.             return workers.Any(w => w.Name.Equals(name));
  64.         }
  65.         public bool IsTeamIn(string name)
  66.         {
  67.             return teams.Any(t => t.Name.Equals(name));
  68.         }
  69.         public IReadOnlyCollection<Member> ListMembers()
  70.         {            
  71.             return workers as IReadOnlyCollection<Member>;
  72.         }
  73.         public IReadOnlyCollection<Team> ListTeam()
  74.         {
  75.             return teams as IReadOnlyCollection<Team>;  
  76.         }
  77.     }
  78. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top