Last change
on this file since d8fafb8 was a55ef91, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago |
Update & add service
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | using FarmatikoData.FarmatikoRepoInterfaces;
|
---|
2 | using FarmatikoData.Models;
|
---|
3 | using System.Linq;
|
---|
4 |
|
---|
5 | namespace FarmatikoData.FarmatikoRepo
|
---|
6 | {
|
---|
7 | public class PharmacyHeadRepository : IPharmacyHeadRepository
|
---|
8 | {
|
---|
9 | private FarmatikoDataContext _context;
|
---|
10 |
|
---|
11 | public PharmacyHeadRepository(FarmatikoDataContext context)
|
---|
12 | {
|
---|
13 | _context = context;
|
---|
14 | }
|
---|
15 |
|
---|
16 | public void Add(PharmacyHead pharmacyHead)
|
---|
17 | {
|
---|
18 | _context.PharmacyHeads.Add(pharmacyHead);
|
---|
19 | _context.SaveChangesAsync();
|
---|
20 | }
|
---|
21 |
|
---|
22 | public IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHeads)
|
---|
23 | {
|
---|
24 | return _context.PharmacyHeads
|
---|
25 | .Where(pharmacyHead => pharmacyHead.Name.Contains(NameOfPharmacyHeads))
|
---|
26 | .OrderBy(x => x.Name);
|
---|
27 | }
|
---|
28 | //Not needed
|
---|
29 | public IQueryable<PharmacyHead> GetPharmacyByName(string Name)
|
---|
30 | {
|
---|
31 | return _context.PharmacyHeads.Where(pharmacyHead => pharmacyHead.Name.Equals(Name));
|
---|
32 | }
|
---|
33 |
|
---|
34 | public IQueryable<MedicineList> GetPharmacyMedicines(string NameOfPharmacy)
|
---|
35 | {
|
---|
36 |
|
---|
37 | IQueryable<MedicineList> Pharmacy = (IQueryable<MedicineList>)_context.PharmacyHeads.Where(x => x.Name.Equals(NameOfPharmacy));
|
---|
38 |
|
---|
39 | return Pharmacy;
|
---|
40 | }
|
---|
41 |
|
---|
42 | public void Remove(PharmacyHead pharmacyHead, string Name)
|
---|
43 | {
|
---|
44 | var phead = (PharmacyHead)_context.PharmacyHeads.Where(phead => phead.Name.Equals(Name)).FirstOrDefault();
|
---|
45 | _context.PharmacyHeads.Remove(phead);
|
---|
46 | _context.SaveChangesAsync();
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.