Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoData/FarmatikoRepo/MedicineListRepository.cs

    rc406ae5 ra55ef91  
    2929        public IQueryable<MedicineList> GetAll()
    3030        {
    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);
     31            return _context.MedicineLists.OrderBy(x => x.Medicine.Name);
    3632        }
    3733
    3834        public ICollection<MedicineList> GetByManufacturer(string Manufacturer)
    3935        {
    40             return (ICollection<MedicineList>)_context.MedicineLists.Take(50)
     36            return (ICollection<MedicineList>)_context.MedicineLists
    4137                .Where(x => x.Medicine.Manufacturer.Contains(Manufacturer))
    42                 .Select(x => new MedicineList
    43                 {
    44                     Medicine = x.Medicine,
    45                     HasMedicine = x.HasMedicine
    46                 })
    4738                .OrderBy(x => x.Medicine.Name)
    4839                .Cast<ICollection<MedicineList>>();
     
    5041        public ICollection<MedicineList> GetByName(string Name)
    5142        {
    52             return (ICollection<MedicineList>)_context.MedicineLists.Take(50)
     43            return (ICollection<MedicineList>)_context.MedicineLists
    5344                .Where(x => x.Medicine.Name.Contains(Name))
    54                 .Select(x => new MedicineList
    55                 {
    56                     Medicine = x.Medicine,
    57                     HasMedicine = x.HasMedicine
    58                 })
    5945                .OrderBy(x => x.Medicine.Name)
    6046                .Cast<ICollection<MedicineList>>();
     
    6349        public void Remove(MedicineList medicineList)
    6450        {
    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             }
     51            var list = (MedicineList)_context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine));
     52            _context.MedicineLists.Remove(list);
    7153        }
    7254    }
Note: See TracChangeset for help on using the changeset viewer.