source: FarmatikoData/FarmatikoRepo/MedicineListRepository.cs@ e42f61a

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

Add more services

  • Property mode set to 100644
File size: 2.0 KB
Line 
1using FarmatikoData.Models;
2using Microsoft.EntityFrameworkCore;
3using System;
4using System.Collections.Generic;
5using System.Linq;
6using System.Text;
7
8namespace FarmatikoData.FarmatikoRepo
9{
10 public class MedicineListRepository : IMedicineListRepository
11 {
12 private FarmatikoDataContext _context;
13 public MedicineListRepository(FarmatikoDataContext context)
14 {
15 _context = context;
16 }
17 public void Add(MedicineList medicineList)
18 {
19 _context.MedicineLists.Add(medicineList);
20 _context.SaveChangesAsync();
21 }
22 // Maybe later
23 /*public MedicineList CheckMedicine(string Name)
24 {
25 return (MedicineList)_context.MedicineLists
26 .Where(medicineList => medicineList.Medicine.Name.Contains(Name))
27 .OrderBy(x => x.Medicine.Name);
28 }*/
29
30 public ICollection<MedicineList> GetAll()
31 {
32 return (ICollection<MedicineList>)_context.MedicineLists.OrderBy(x => x.Medicine.Name);
33 }
34
35 public ICollection<MedicineList> GetByManufacturer(string Manufacturer)
36 {
37 return (ICollection<MedicineList>)_context.MedicineLists
38 .Where(x => x.Medicine.Manufacturer.Contains(Manufacturer))
39 .OrderBy(x => x.Medicine.Name);
40 }
41 public ICollection<MedicineList> GetByName(string Name)
42 {
43 return (ICollection<MedicineList>)_context.MedicineLists
44 .Where(x => x.Medicine.Name.Contains(Name))
45 .OrderBy(x => x.Medicine.Name);
46 }
47
48 public void Remove(MedicineList medicineList)
49 {
50 var list = (MedicineList)_context.MedicineLists.Where(x => x.Equals(medicineList));
51 _context.Remove(list);
52 }
53
54 public void SetHasMedicine(MedicineList medicineList, bool HasMedicine)
55 {
56 var medicine = _context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine));
57 }
58 }
59}
Note: See TracBrowser for help on using the repository browser.