source: FarmatikoData/FarmatikoRepo/MedicineListRepository.cs@ e42f61a

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

Add more services

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[37c8d1d]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 }
[e42f61a]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 }*/
[37c8d1d]29
[e42f61a]30 public ICollection<MedicineList> GetAll()
[37c8d1d]31 {
[e42f61a]32 return (ICollection<MedicineList>)_context.MedicineLists.OrderBy(x => x.Medicine.Name);
[37c8d1d]33 }
34
[e42f61a]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)
[37c8d1d]42 {
[e42f61a]43 return (ICollection<MedicineList>)_context.MedicineLists
44 .Where(x => x.Medicine.Name.Contains(Name))
45 .OrderBy(x => x.Medicine.Name);
[37c8d1d]46 }
47
48 public void Remove(MedicineList medicineList)
49 {
[e42f61a]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));
[37c8d1d]57 }
58 }
59}
Note: See TracBrowser for help on using the repository browser.