source: FarmatikoData/FarmatikoRepo/PharmacyHeadRepository.cs@ de2baac

Last change on this file since de2baac was de2baac, checked in by DimitarSlezenkovski <dslezenkovski@…>, 2 years ago

Add classes & interfaces for Repo

  • Property mode set to 100644
File size: 1.3 KB
Line 
1using FarmatikoData.FarmatikoRepoInterfaces;
2using FarmatikoData.Models;
3using System;
4using System.Collections.Generic;
5using System.Linq;
6using System.Text;
7
8namespace FarmatikoData.FarmatikoRepo
9{
10 public class PharmacyHeadRepository : IPharmacyHeadRepository
11 {
12 private FarmatikoDataContext _context;
13
14 public PharmacyHeadRepository(FarmatikoDataContext context)
15 {
16 _context = context;
17 }
18
19 public void Add(PharmacyHead pharmacyHead)
20 {
21 _context.PharmacyHeads.Add(pharmacyHead);
22 _context.SaveChangesAsync();
23 }
24
25 public ICollection<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHead)
26 {
27 return (ICollection<PharmacyHead>)_context.PharmacyHeads.Where(pharmacyHead => pharmacyHead.Name.Equals(NameOfPharmacyHead));
28 }
29 //Not needed
30 public IEnumerable<PharmacyHead> GetPharmacyByName(string Name)
31 {
32 return _context.PharmacyHeads.Where(pharmacyHead => pharmacyHead.Name.Equals(Name));
33 }
34
35 public void Remove(PharmacyHead pharmacyHead, string Name)
36 {
37 var phead = (PharmacyHead)_context.PharmacyHeads.Where(phead => phead.Name.Equals(Name));
38 _context.PharmacyHeads.Remove(phead);
39 _context.SaveChangesAsync();
40 }
41 }
42}
Note: See TracBrowser for help on using the repository browser.