Last change
on this file since d2e69be was d2e69be, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago |
Add Route Attribute
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[37c8d1d] | 1 | using FarmatikoData.FarmatikoRepoInterfaces;
|
---|
| 2 | using System;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Collections.Generic;
|
---|
| 5 | using System.Text;
|
---|
| 6 | using FarmatikoData.Models;
|
---|
| 7 | using Microsoft.EntityFrameworkCore;
|
---|
| 8 |
|
---|
| 9 | namespace FarmatikoData.FarmatikoRepo
|
---|
| 10 | {
|
---|
| 11 | public class HealthFacilityRepository : IHealthFacilityRepository
|
---|
| 12 | {
|
---|
| 13 | private FarmatikoDataContext _context;
|
---|
| 14 |
|
---|
| 15 | public HealthFacilityRepository(FarmatikoDataContext context)
|
---|
| 16 | {
|
---|
| 17 | _context = context;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | public void Add(HealthFacilities healthFacility)
|
---|
| 21 | {
|
---|
| 22 | _context.Add(healthFacility);
|
---|
| 23 | _context.SaveChangesAsync();
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | public IEnumerable<HealthFacilities> GetAll()
|
---|
| 27 | {
|
---|
[d2e69be] | 28 | return _context.HealthFacilities.OrderBy(x => x.Name).ToList();
|
---|
[37c8d1d] | 29 | }
|
---|
| 30 |
|
---|
[d2e69be] | 31 | public IEnumerable<HealthFacilities> GetAllByName(string Name)
|
---|
[37c8d1d] | 32 | {
|
---|
[d2e69be] | 33 | Name = Name.ToLower();
|
---|
[37c8d1d] | 34 |
|
---|
[d2e69be] | 35 | return _context.HealthFacilities.Where(x => x.Name.ToLower().Contains(Name)).OrderBy(x => x.Name.ToLower().IndexOf(Name)).ToList();
|
---|
[37c8d1d] | 36 | }
|
---|
| 37 |
|
---|
[d2e69be] | 38 | IEnumerable<HealthFacilities> IHealthFacilityRepository.GetByType(string Type)
|
---|
[37c8d1d] | 39 | {
|
---|
[d2e69be] | 40 | return (IEnumerable<HealthFacilities>)_context.HealthFacilities
|
---|
| 41 | .Where(type => type.Type.Equals(Type));
|
---|
[37c8d1d] | 42 | }
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.