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/HealthFacilityRepository.cs

    ree137aa r63d885e  
    1616        public void Add(HealthFacilities healthFacility)
    1717        {
    18             _context.Add(healthFacility);
    19             _context.SaveChanges();
     18             _context.HealthFacilities.Add(healthFacility);
     19            _context.SaveChangesAsync();
    2020        }
    2121
    2222        public IQueryable<HealthFacilities> GetAll()
    2323        {
    24             return _context.HealthFacilities.OrderBy(x => x.Name);
     24            return _context.HealthFacilities.Take(50).Select(x => new HealthFacilities
     25            {
     26                Name = x.Name,
     27                Municipality = x.Municipality,
     28                Address = x.Address,
     29                Type = x.Type,
     30                Email = x.Email,
     31                Phone = x.Phone
     32            }).OrderBy(x => x.Name);
     33        }
     34
     35        public IQueryable<HealthFacilities> GetByName(string Name)
     36        {
     37            return _context.HealthFacilities.Where(x => x.Name.Equals(Name));
    2538        }
    2639
    2740        public void Remove(HealthFacilities healthFacility)
    2841        {
    29             var facility = _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility.Name));
    30             _context.HealthFacilities.Remove((HealthFacilities)facility);
     42            var facility = _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility.Name)).FirstOrDefault();
     43            if (facility != null)
     44            {
     45                _context.HealthFacilities.Remove(facility);
     46                _context.SaveChangesAsync();
     47            }
     48           
    3149        }
    3250    }
Note: See TracChangeset for help on using the changeset viewer.