[37c8d1d] | 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 | }
|
---|
[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 | }
|
---|