- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/MedicineListRepository.cs
ra55ef91 rc406ae5 29 29 public IQueryable<MedicineList> GetAll() 30 30 { 31 return _context.MedicineLists.OrderBy(x => x.Medicine.Name); 31 return _context.MedicineLists.Take(50).Select(x => new MedicineList 32 { 33 Medicine = x.Medicine, 34 HasMedicine = x.HasMedicine 35 }).OrderBy(x => x.Medicine.Name); 32 36 } 33 37 34 38 public ICollection<MedicineList> GetByManufacturer(string Manufacturer) 35 39 { 36 return (ICollection<MedicineList>)_context.MedicineLists 40 return (ICollection<MedicineList>)_context.MedicineLists.Take(50) 37 41 .Where(x => x.Medicine.Manufacturer.Contains(Manufacturer)) 42 .Select(x => new MedicineList 43 { 44 Medicine = x.Medicine, 45 HasMedicine = x.HasMedicine 46 }) 38 47 .OrderBy(x => x.Medicine.Name) 39 48 .Cast<ICollection<MedicineList>>(); … … 41 50 public ICollection<MedicineList> GetByName(string Name) 42 51 { 43 return (ICollection<MedicineList>)_context.MedicineLists 52 return (ICollection<MedicineList>)_context.MedicineLists.Take(50) 44 53 .Where(x => x.Medicine.Name.Contains(Name)) 54 .Select(x => new MedicineList 55 { 56 Medicine = x.Medicine, 57 HasMedicine = x.HasMedicine 58 }) 45 59 .OrderBy(x => x.Medicine.Name) 46 60 .Cast<ICollection<MedicineList>>(); … … 49 63 public void Remove(MedicineList medicineList) 50 64 { 51 var list = (MedicineList)_context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine)); 52 _context.MedicineLists.Remove(list); 65 var list = _context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine)).FirstOrDefault(); 66 if (list != null) 67 { 68 _context.MedicineLists.Remove(list); 69 _context.SaveChangesAsync(); 70 } 53 71 } 54 72 }
Note:
See TracChangeset
for help on using the changeset viewer.