Changeset a55ef91 for FarmatikoData/FarmatikoRepo/MedicineListRepository.cs
- Timestamp:
- 07/31/20 10:15:02 (5 years ago)
- Branches:
- master
- Children:
- d8fafb8
- Parents:
- 4e72684
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/MedicineListRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.Models; 2 using Microsoft.EntityFrameworkCore; 2 3 using System.Collections.Generic; 3 4 using System.Linq; … … 17 18 _context.SaveChangesAsync(); 18 19 } 19 public MedicineList CheckMedicine(string Name)20 /*public MedicineList CheckMedicine(string Name) 20 21 { 21 22 return (MedicineList)_context.MedicineLists 22 23 .Where(medicineList => medicineList.Medicine.Name.Contains(Name)) 23 .OrderBy(x => x.Medicine.Name); 24 } 25 26 public IEnumerable<MedicineList> GetAll() 24 .OrderBy(x => x.Medicine.Name) 25 .Include(x => x.HasMedicine) 26 .Cast<MedicineList>(); 27 }*/ 28 29 public IQueryable<MedicineList> GetAll() 27 30 { 28 31 return _context.MedicineLists.OrderBy(x => x.Medicine.Name); … … 33 36 return (ICollection<MedicineList>)_context.MedicineLists 34 37 .Where(x => x.Medicine.Manufacturer.Contains(Manufacturer)) 35 .OrderBy(x => x.Medicine.Name); 38 .OrderBy(x => x.Medicine.Name) 39 .Cast<ICollection<MedicineList>>(); 36 40 } 37 41 public ICollection<MedicineList> GetByName(string Name) … … 39 43 return (ICollection<MedicineList>)_context.MedicineLists 40 44 .Where(x => x.Medicine.Name.Contains(Name)) 41 .OrderBy(x => x.Medicine.Name); 45 .OrderBy(x => x.Medicine.Name) 46 .Cast<ICollection<MedicineList>>(); 42 47 } 43 48 44 49 public void Remove(MedicineList medicineList) 45 50 { 46 var list = (MedicineList)_context.MedicineLists.Where(x => x. Equals(medicineList));51 var list = (MedicineList)_context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine)); 47 52 _context.MedicineLists.Remove(list); 48 }49 50 public bool SetHasMedicine(MedicineList medicineList, bool HasMedicine)51 {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 else64 {65 medicine.HasMedicine = HasMedicine;66 _context.MedicineLists.Add(medicine);67 _context.SaveChangesAsync();68 return true;69 }70 }else71 {72 return false;73 }74 53 } 75 54 }
Note:
See TracChangeset
for help on using the changeset viewer.