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 | {
|
---|
28 | return _context.HealthFacilities;
|
---|
29 | }
|
---|
30 |
|
---|
31 | public HealthFacilities GetByFullName(string FullName)
|
---|
32 | {
|
---|
33 | return (HealthFacilities)_context.HealthFacilities
|
---|
34 | .Where(Facility => Facility.Name == FullName)
|
---|
35 | .FirstOrDefault(Facility => Facility.Name == FullName);
|
---|
36 | }
|
---|
37 |
|
---|
38 | public HealthFacilities GetByType(string FacilityType)
|
---|
39 | {
|
---|
40 | return (HealthFacilities)_context.HealthFacilities
|
---|
41 | .Where(FacilityType => FacilityType.Type.Equals(FacilityType))
|
---|
42 | .FirstOrDefault(FacilityType => FacilityType.Name.Equals(FacilityType));
|
---|
43 | }
|
---|
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 |
|
---|
52 | }
|
---|
53 | }
|
---|