- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/MedicineRepository.cs
rc406ae5 ra55ef91 21 21 public IQueryable<Medicine> GetAll() 22 22 { 23 return _context.Medicines.Take(50).Select(x => new Medicine 24 { 25 Name = x.Name, 26 Strength = x.Strength, 27 Form = x.Form, 28 WayOfIssuing = x.WayOfIssuing, 29 Manufacturer = x.Manufacturer, 30 Price = x.Price, 31 Packaging = x.Packaging 32 }).OrderBy(x => x.Name); 23 return _context.Medicines.OrderBy(x => x.Name); 33 24 } 34 25 35 26 public IQueryable<Medicine> GetByManufacturer(string Manufacturer) 36 27 { 37 return _context.Medicines.Take(50).Where(x => x.Name.Contains(Manufacturer)) 38 .Select(x => new Medicine 39 { 40 Name = x.Name, 41 Strength = x.Strength, 42 Form = x.Form, 43 WayOfIssuing = x.WayOfIssuing, 44 Manufacturer = x.Manufacturer, 45 Price = x.Price, 46 Packaging = x.Packaging 47 }).OrderBy(x => x.Manufacturer); 28 return _context.Medicines.Where(x => x.Name.Contains(Manufacturer)).OrderBy(x => x.Manufacturer); 48 29 } 49 30 50 31 public IQueryable<Medicine> GetByName(string Name) 51 32 { 52 return _context.Medicines.Take(50).Where(medicine => medicine.Name.Contains(Name)) 53 .Select(x => new Medicine 54 { 55 Name = x.Name, 56 Strength = x.Strength, 57 Form = x.Form, 58 WayOfIssuing = x.WayOfIssuing, 59 Manufacturer = x.Manufacturer, 60 Price = x.Price, 61 Packaging = x.Packaging 62 }).OrderBy(x => x.Name); 33 return _context.Medicines.Where(medicine => medicine.Name.Contains(Name)).OrderBy(x => x.Name); 63 34 } 64 35 65 public void Remove( Medicinemedicine)36 public void Remove(string medicine) 66 37 { 67 Medicine med = _context.Medicines.Where(medicine => medicine.Name.Equals(medicine.Name)).FirstOrDefault(); 68 if (med != null) 69 { 70 _context.Medicines.Remove(med); 71 _context.SaveChangesAsync(); 72 } 73 38 Medicine med = (Medicine)_context.Medicines.Where(medicine => medicine.Name.Equals(medicine)); 39 _context.Medicines.Remove(med); 74 40 } 75 41 }
Note:
See TracChangeset
for help on using the changeset viewer.