Changeset 4e72684 for FarmatikoData/FarmatikoRepo
- Timestamp:
- 07/29/20 20:02:58 (4 years ago)
- Branches:
- master
- Children:
- a55ef91
- Parents:
- de18858
- Location:
- FarmatikoData/FarmatikoRepo
- Files:
-
- 4 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 } -
FarmatikoData/FarmatikoRepo/MedicineRepository.cs
rde18858 r4e72684 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using Microsoft.EntityFrameworkCore;4 using System;5 3 using System.Collections.Generic; 6 4 using System.Linq; 7 using System.Text;8 5 9 6 namespace FarmatikoData.FarmatikoRepo … … 24 21 public IEnumerable<Medicine> GetAll() 25 22 { 26 return _context.Medicines. Include(medicine => medicine.Name).Include(medicine => medicine.Strength).Include(medicine => medicine.Form);23 return _context.Medicines.OrderBy(x => x.Name); 27 24 } 28 25 … … 34 31 public IEnumerable<Medicine> GetByName(string Name) 35 32 { 36 return (IEnumerable<Medicine>)_context.Medicines.Where(medicine => medicine.Name == Name);33 return _context.Medicines.Where(medicine => medicine.Name == Name); 37 34 } 38 35 … … 40 37 { 41 38 Medicine med = (Medicine)_context.Medicines.Where(medicine => medicine.Name.Equals(medicine)); 42 _context. Remove(med);39 _context.Medicines.Remove(med); 43 40 } 44 41 } -
FarmatikoData/FarmatikoRepo/PharmacyHeadRepository.cs
rde18858 r4e72684 23 23 } 24 24 25 public I Collection<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHead)25 public IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHeads) 26 26 { 27 return (ICollection<PharmacyHead>)_context.PharmacyHeads.Where(pharmacyHead => pharmacyHead.Name.Equals(NameOfPharmacyHead)); 27 return _context.PharmacyHeads 28 .Where(pharmacyHead => pharmacyHead.Name.Contains(NameOfPharmacyHeads)) 29 .OrderBy(x => x.Name); 28 30 } 29 31 //Not needed 30 public I Enumerable<PharmacyHead> GetPharmacyByName(string Name)32 public IQueryable<PharmacyHead> GetPharmacyByName(string Name) 31 33 { 32 34 return _context.PharmacyHeads.Where(pharmacyHead => pharmacyHead.Name.Equals(Name)); 35 } 36 37 public IQueryable<MedicineList> GetPharmacyMedicines(string NameOfPharmacy) 38 { 39 40 IQueryable<MedicineList> Pharmacy = (IQueryable<MedicineList>)_context.PharmacyHeads.Where(x => x.Name.Equals(NameOfPharmacy)); 41 42 return Pharmacy; 33 43 } 34 44 -
FarmatikoData/FarmatikoRepo/PharmacyRepository.cs
rde18858 r4e72684 21 21 _context.Pharmacies.Add(pharmacy); 22 22 _context.SaveChangesAsync(); 23 } 24 //Just for users 25 public IEnumerable<Pharmacy> GetAll() 26 { 27 return _context.Pharmacies.OrderBy(x => x.Name); 23 28 } 24 29
Note:
See TracChangeset
for help on using the changeset viewer.