Ignore:
Timestamp:
08/07/20 11:01:25 (4 years ago)
Author:
Mile Jankuloski <mile.jankuloski@…>
Branches:
master
Children:
5d02859
Parents:
ee137aa (diff), c406ae5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of https://develop.finki.ukim.mk/git/farmatiko

File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoData/FarmatikoRepo/MedicineListRepository.cs

    ree137aa r63d885e  
    2929        public IQueryable<MedicineList> GetAll()
    3030        {
    31             return _context.MedicineLists.OrderBy(x => x.Medicine.Name);
     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);
    3236        }
    3337
    3438        public ICollection<MedicineList> GetByManufacturer(string Manufacturer)
    3539        {
    36             return (ICollection<MedicineList>)_context.MedicineLists
     40            return (ICollection<MedicineList>)_context.MedicineLists.Take(50)
    3741                .Where(x => x.Medicine.Manufacturer.Contains(Manufacturer))
     42                .Select(x => new MedicineList
     43                {
     44                    Medicine = x.Medicine,
     45                    HasMedicine = x.HasMedicine
     46                })
    3847                .OrderBy(x => x.Medicine.Name)
    3948                .Cast<ICollection<MedicineList>>();
     
    4150        public ICollection<MedicineList> GetByName(string Name)
    4251        {
    43             return (ICollection<MedicineList>)_context.MedicineLists
     52            return (ICollection<MedicineList>)_context.MedicineLists.Take(50)
    4453                .Where(x => x.Medicine.Name.Contains(Name))
     54                .Select(x => new MedicineList
     55                {
     56                    Medicine = x.Medicine,
     57                    HasMedicine = x.HasMedicine
     58                })
    4559                .OrderBy(x => x.Medicine.Name)
    4660                .Cast<ICollection<MedicineList>>();
     
    4963        public void Remove(MedicineList medicineList)
    5064        {
    51             var list = (MedicineList)_context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine));
    52             _context.MedicineLists.Remove(list);
     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            }
    5371        }
    5472    }
Note: See TracChangeset for help on using the changeset viewer.