Ignore:
Timestamp:
07/27/20 17:10:07 (4 years ago)
Author:
DimitarSlezenkovski <dslezenkovski@…>
Branches:
master
Children:
ef1219a
Parents:
4b342bb
Message:

Add Route Attribute

File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoData/FarmatikoRepo/HealthFacilityRepository.cs

    r4b342bb rd2e69be  
    2626        public IEnumerable<HealthFacilities> GetAll()
    2727        {
    28             return _context.HealthFacilities;
     28            return _context.HealthFacilities.OrderBy(x => x.Name).ToList();
    2929        }
    3030
    31         public HealthFacilities GetByFullName(string FullName)
     31        public IEnumerable<HealthFacilities> GetAllByName(string Name)
    3232        {
    33             return (HealthFacilities)_context.HealthFacilities
    34                 .Where(Facility => Facility.Name == FullName)
    35                 .FirstOrDefault(Facility => Facility.Name == FullName);
     33            Name = Name.ToLower();
     34
     35            return _context.HealthFacilities.Where(x => x.Name.ToLower().Contains(Name)).OrderBy(x => x.Name.ToLower().IndexOf(Name)).ToList();
    3636        }
    3737
    38         public HealthFacilities GetByType(string FacilityType)
     38        IEnumerable<HealthFacilities> IHealthFacilityRepository.GetByType(string Type)
    3939        {
    40             return (HealthFacilities)_context.HealthFacilities
    41                 .Where(FacilityType => FacilityType.Type.Equals(FacilityType))
    42                 .FirstOrDefault(FacilityType => FacilityType.Name.Equals(FacilityType));
     40            return (IEnumerable<HealthFacilities>)_context.HealthFacilities
     41               .Where(type => type.Type.Equals(Type));
    4342        }
    44 
    45         public void Remove(string healthFacility)
    46         {
    47             HealthFacilities Facility = (HealthFacilities)_context.HealthFacilities.Where(healthFacility => healthFacility.Name.Equals(healthFacility));
    48             _context.Remove(Facility);
    49             _context.SaveChangesAsync();
    50         }
    51 
    5243    }
    5344}
Note: See TracChangeset for help on using the changeset viewer.