- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/MedicineRepository.cs
ra55ef91 rc406ae5 21 21 public IQueryable<Medicine> GetAll() 22 22 { 23 return _context.Medicines.OrderBy(x => x.Name); 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); 24 33 } 25 34 26 35 public IQueryable<Medicine> GetByManufacturer(string Manufacturer) 27 36 { 28 return _context.Medicines.Where(x => x.Name.Contains(Manufacturer)).OrderBy(x => x.Manufacturer); 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); 29 48 } 30 49 31 50 public IQueryable<Medicine> GetByName(string Name) 32 51 { 33 return _context.Medicines.Where(medicine => medicine.Name.Contains(Name)).OrderBy(x => x.Name); 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); 34 63 } 35 64 36 public void Remove( stringmedicine)65 public void Remove(Medicine medicine) 37 66 { 38 Medicine med = (Medicine)_context.Medicines.Where(medicine => medicine.Name.Equals(medicine)); 39 _context.Medicines.Remove(med); 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 40 74 } 41 75 }
Note:
See TracChangeset
for help on using the changeset viewer.