Changeset 4e72684 for FarmatikoData/FarmatikoRepo/MedicineListRepository.cs
- Timestamp:
- 07/29/20 20:02:58 (5 years ago)
- Branches:
- master
- Children:
- a55ef91
- Parents:
- de18858
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/MedicineListRepository.cs
rde18858 r4e72684 1 1 using FarmatikoData.Models; 2 using Microsoft.EntityFrameworkCore;3 using System;4 2 using System.Collections.Generic; 5 3 using System.Linq; 6 using System.Text;7 4 8 5 namespace FarmatikoData.FarmatikoRepo … … 20 17 _context.SaveChangesAsync(); 21 18 } 22 // Maybe later 23 /*public MedicineList CheckMedicine(string Name) 19 public MedicineList CheckMedicine(string Name) 24 20 { 25 21 return (MedicineList)_context.MedicineLists 26 22 .Where(medicineList => medicineList.Medicine.Name.Contains(Name)) 27 23 .OrderBy(x => x.Medicine.Name); 28 } */24 } 29 25 30 public I Collection<MedicineList> GetAll()26 public IEnumerable<MedicineList> GetAll() 31 27 { 32 return (ICollection<MedicineList>)_context.MedicineLists.OrderBy(x => x.Medicine.Name);28 return _context.MedicineLists.OrderBy(x => x.Medicine.Name); 33 29 } 34 30 … … 49 45 { 50 46 var list = (MedicineList)_context.MedicineLists.Where(x => x.Equals(medicineList)); 51 _context. Remove(list);47 _context.MedicineLists.Remove(list); 52 48 } 53 49 54 public voidSetHasMedicine(MedicineList medicineList, bool HasMedicine)50 public bool SetHasMedicine(MedicineList medicineList, bool HasMedicine) 55 51 { 56 var medicine = _context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine)); 52 MedicineList medicine = (MedicineList)_context.MedicineLists.Where(x => x.Medicine.Name.Equals(medicineList.Medicine.Name)); 53 54 if (medicine != null || medicineList != null) 55 { 56 if (HasMedicine == true) 57 { 58 medicine.HasMedicine = HasMedicine; 59 _context.MedicineLists.Add(medicine); 60 _context.SaveChangesAsync(); 61 return true; 62 } 63 else 64 { 65 medicine.HasMedicine = HasMedicine; 66 _context.MedicineLists.Add(medicine); 67 _context.SaveChangesAsync(); 68 return true; 69 } 70 }else 71 { 72 return false; 73 } 57 74 } 58 75 }
Note:
See TracChangeset
for help on using the changeset viewer.