Last change
on this file was f554983, checked in by Dimitar Slezenkovski <dslezenkovski@…>, 4 years ago |
Add cron job for updating data, with Quartz.NET
|
-
Property mode
set to
100644
|
File size:
2.0 KB
|
Line | |
---|
1 | using FarmatikoData.FarmatikoRepoInterfaces;
|
---|
2 | using FarmatikoData.Models;
|
---|
3 | using System;
|
---|
4 | using System.Collections.Generic;
|
---|
5 | using System.Linq;
|
---|
6 | using System.Text;
|
---|
7 | using System.Threading.Tasks;
|
---|
8 |
|
---|
9 | namespace FarmatikoData.FarmatikoRepo
|
---|
10 | {
|
---|
11 | public class UpdateDataRepo : IUpdateDataRepo
|
---|
12 | {
|
---|
13 | private readonly FarmatikoDataContext _context;
|
---|
14 | public UpdateDataRepo(FarmatikoDataContext context)
|
---|
15 | {
|
---|
16 | _context = context;
|
---|
17 | }
|
---|
18 | public async Task AddPharmacy(Pharmacy pharmacy)
|
---|
19 | {
|
---|
20 | pharmacy.Id = 0;
|
---|
21 | if (pharmacy.Id == 0)
|
---|
22 | {
|
---|
23 | var phars = _context.Pharmacies.Select(x => new Pharmacy
|
---|
24 | {
|
---|
25 | Name = x.Name,
|
---|
26 | Location = x.Location,
|
---|
27 | Address = x.Address
|
---|
28 | }).ToList();
|
---|
29 | var pharms = phars.Where(x => x.Name.Equals(pharmacy.Name) && x.Location.Equals(pharmacy.Location) && x.Address.Equals(pharmacy.Address)).ToList();
|
---|
30 | if (pharms is null || pharms.Count() == 0)
|
---|
31 | {
|
---|
32 | await _context.Pharmacies.AddAsync(pharmacy);
|
---|
33 | _context.SaveChanges();
|
---|
34 | }
|
---|
35 |
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
39 | public async Task AddFacility(HealthFacility healthFacility)
|
---|
40 | {
|
---|
41 | await _context.HealthFacilities.AddAsync(healthFacility);
|
---|
42 | _context.SaveChanges();
|
---|
43 | }
|
---|
44 | public async Task AddWorker(HealthcareWorker Worker)
|
---|
45 | {
|
---|
46 | await _context.HealthcareWorkers.AddAsync(Worker);
|
---|
47 | _context.SaveChanges();
|
---|
48 | }
|
---|
49 |
|
---|
50 | public async Task AddMedicines(Medicine medicine)
|
---|
51 | {
|
---|
52 | await _context.Medicines.AddAsync(medicine);
|
---|
53 | _context.SaveChanges();
|
---|
54 | }
|
---|
55 |
|
---|
56 | public HealthFacility GetFacilityJSON(string healthFacility)
|
---|
57 | {
|
---|
58 | var Facility = _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility)).FirstOrDefault();
|
---|
59 | return Facility;
|
---|
60 | }
|
---|
61 | }
|
---|
62 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.