1 | using FarmatikoData.Models;
|
---|
2 | using Microsoft.EntityFrameworkCore;
|
---|
3 | using System;
|
---|
4 | using System.Collections.Generic;
|
---|
5 | using System.Linq;
|
---|
6 | using System.Text;
|
---|
7 |
|
---|
8 | namespace 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 | }
|
---|