source: FarmatikoData/FarmatikoRepo/HealthcareWorkerRepository.cs@ c406ae5

Last change on this file since c406ae5 was c406ae5, checked in by DimitarSlezenkovski <dslezenkovski@…>, 2 years ago

Update Models, Repos, Services and Controllers

  • Property mode set to 100644
File size: 1.3 KB
Line 
1using FarmatikoData.FarmatikoRepoInterfaces;
2using FarmatikoData.Models;
3using System.Linq;
4using System.Threading.Tasks;
5
6namespace FarmatikoData.FarmatikoRepo
7{
8 public class HealthcareWorkerRepository : IHealthcareWorkerRepository
9 {
10
11 private FarmatikoDataContext _context;
12
13 public HealthcareWorkerRepository(FarmatikoDataContext context)
14 {
15 _context = context;
16 }
17
18 public void Add(HealthcareWorkers HealthcareWorker)
19 {
20 _context.HealthcareWorkers.Add(HealthcareWorker);
21 _context.SaveChangesAsync();
22 }
23
24 public IQueryable<HealthcareWorkers> GetAll()
25 {
26 return _context.HealthcareWorkers.Take(50).Select(x => new HealthcareWorkers
27 {
28 Name = x.Name,
29 Branch = x.Branch,
30 Facility = x.Facility,
31 Title = x.Title
32 }).OrderBy(x => x.Name);
33 }
34
35 public void Remove(HealthcareWorkers healthcareWorker)
36 {
37 var healthCareWorker = _context.HealthcareWorkers.Where(x => x.Name.Equals(healthcareWorker.Name)).FirstOrDefault();
38 if (healthCareWorker != null)
39 {
40 _context.HealthcareWorkers.Remove(healthCareWorker);
41 _context.SaveChangesAsync();
42 }
43
44 }
45 }
46}
Note: See TracBrowser for help on using the repository browser.