Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.09 KB | None | 0 0
  1. using FurnitureManufacturer.Interfaces;
  2. using FurnitureManufacturer.Interfaces.Engine;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7.  
  8. namespace FurnitureManufacturer.Engine
  9. {
  10.     public class Database : IDatabase
  11.     {
  12.         private readonly IDictionary<string, ICompany> companies;
  13.         private readonly IDictionary<string, IFurniture> furnitures;
  14.  
  15.         public Database()
  16.         {
  17.             this.companies = new Dictionary<string, ICompany>();
  18.             this.furnitures = new Dictionary<string, IFurniture>();
  19.         }
  20.  
  21.         public IDictionary<string, ICompany> Companies
  22.         {
  23.             get
  24.             {
  25.                 return new Dictionary<string, ICompany>(this.companies);
  26.             }
  27.  
  28.         }
  29.  
  30.         public IDictionary<string, IFurniture> Furnitures
  31.         {
  32.             get
  33.             {
  34.                 return new Dictionary<string, IFurniture>(this.furnitures);
  35.             }
  36.  
  37.         }
  38.  
  39.         public void AddCompanyToCompanies(ICompany company)
  40.         {
  41.             this.companies.Add(company.Name, company);
  42.         }
  43.  
  44.         public void RemoveCompanyToCompanies(ICompany company)
  45.         {
  46.             this.companies.Remove(company.Name);
  47.         }
  48.  
  49.         public void AddFurnitureToFurniture(IFurniture furniture)
  50.         {
  51.             this.furnitures.Add(furniture.Model, furniture);
  52.         }
  53.  
  54.         public void RemoveFurnitureToFurniture(IFurniture furniture)
  55.         {
  56.             this.furnitures.Remove(furniture.Model);
  57.         }
  58.  
  59.  
  60.         public bool IsCompanyPresentInCollection(string name)
  61.         {
  62.             bool contains = this.companies.ContainsKey(name);
  63.  
  64.             if (contains)
  65.             {
  66.                 return true;
  67.             }
  68.  
  69.             return false;
  70.         }
  71.  
  72.         public bool IsFurniturePresentInCollection(string name)
  73.         {
  74.             bool contains = this.furnitures.ContainsKey(name);
  75.  
  76.             if (contains)
  77.             {
  78.                 return true;
  79.             }
  80.  
  81.             return false;
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement