Ignore:
Timestamp:
08/07/20 11:01:25 (3 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/PharmacyHeadRepository.cs

    ree137aa r63d885e  
    2222        public IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHeads)
    2323        {
    24             return _context.PharmacyHeads
    25                 .Where(pharmacyHead => pharmacyHead.Name.Contains(NameOfPharmacyHeads))
    26                 .OrderBy(x => x.Name);
     24            return _context.PharmacyHeads.Where(pharmacyHead => pharmacyHead.Name.Contains(NameOfPharmacyHeads))
     25                .Take(10).Select(x => new PharmacyHead
     26                {
     27                    MedicineLists = x.MedicineLists,
     28                    PharmaciesList = x.PharmaciesList,
     29                    Email = x.Email,
     30                    Name = x.Name,
     31                }).OrderBy(x => x.Name);
    2732        }
    2833        //Not needed
    2934        public IQueryable<PharmacyHead> GetPharmacyByName(string Name)
    3035        {
    31             return _context.PharmacyHeads.Where(pharmacyHead => pharmacyHead.Name.Equals(Name));
     36            return _context.PharmacyHeads.Take(10)
     37                .Where(pharmacyHead => pharmacyHead.Name.Equals(Name))
     38                .Select(x => new PharmacyHead
     39                {
     40                    MedicineLists = x.MedicineLists,
     41                    PharmaciesList = x.PharmaciesList,
     42                    Email = x.Email,
     43                    Name = x.Name,
     44                }).OrderBy(x => x.Name);
    3245        }
    3346
     
    3548        {
    3649
    37             IQueryable<MedicineList> Pharmacy = (IQueryable<MedicineList>)_context.PharmacyHeads.Where(x => x.Name.Equals(NameOfPharmacy));
    38            
     50            IQueryable<MedicineList> Pharmacy = (IQueryable<MedicineList>)_context.PharmacyHeads
     51                .Take(50)
     52                .Where(x => x.Name.Equals(NameOfPharmacy))
     53                .Select(x => new PharmacyHead
     54                {
     55                    MedicineLists = x.MedicineLists
     56                }).OrderBy(x => x.Name);
     57
    3958            return Pharmacy;
    4059        }
    4160
    42         public void Remove(PharmacyHead pharmacyHead, string Name)
     61        public void Remove(PharmacyHead pharmacyHead)
    4362        {
    44             var phead = (PharmacyHead)_context.PharmacyHeads.Where(phead => phead.Name.Equals(Name)).FirstOrDefault();
    45             _context.PharmacyHeads.Remove(phead);
    46             _context.SaveChangesAsync();
     63            var phead = _context.PharmacyHeads.Where(phead => phead.Name.Equals(pharmacyHead.Name)).FirstOrDefault();
     64            if (phead != null)
     65            {
     66                _context.PharmacyHeads.Remove(phead);
     67                _context.SaveChangesAsync();
     68            }
    4769        }
    4870    }
Note: See TracChangeset for help on using the changeset viewer.