source: FarmatikoData/FarmatikoRepo/HealthcareWorkersRepository.cs@ 37c8d1d

Last change on this file since 37c8d1d was 37c8d1d, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

Add FarmatikoRepository and FarmatikoServices

  • Property mode set to 100644
File size: 1.4 KB
Line 
1using FarmatikoData.FarmatikoRepoInterfaces;
2using FarmatikoData.Models;
3using System;
4using System.Linq;
5using System.Collections.Generic;
6using System.Text;
7using Microsoft.EntityFrameworkCore;
8
9namespace FarmatikoData.FarmatikoRepo
10{
11 public class HealthcareWorkersRepository : IHealthcareWorkersRepository
12 {
13
14 private FarmatikoDataContext _context;
15
16 public HealthcareWorkersRepository(FarmatikoDataContext context)
17 {
18 _context = context;
19 }
20
21 public void Add(HealthcareWorkers HealthcareWorker)
22 {
23 _context.Add(HealthcareWorker);
24 _context.SaveChangesAsync();
25 }
26
27 public IEnumerable<HealthcareWorkers> GetAll()
28 {
29 return _context.HealthcareWorkers;
30 }
31
32 public ICollection<HealthcareWorkers> GetByBranch(string Branch)
33 {
34 return (ICollection<HealthcareWorkers>)_context.HealthcareWorkers.Where(healthcareWorker => healthcareWorker.Branch == Branch);
35 }
36
37 public ICollection<HealthcareWorkers> GetByFacility(HealthFacilities HealthFacility)
38 {
39 return (ICollection<HealthcareWorkers>)_context.HealthcareWorkers.Where(Facility => Facility.Facility.Equals(HealthFacility));
40 }
41
42 public HealthcareWorkers GetByName(string Name)
43 {
44 return (HealthcareWorkers)_context.HealthcareWorkers.Where(healthcareWorker => healthcareWorker.Name == Name);
45 }
46 }
47}
Note: See TracBrowser for help on using the repository browser.