Changeset 6f203af for FarmatikoData
- Timestamp:
- 10/28/20 22:06:48 (4 years ago)
- Branches:
- master
- Children:
- 993189e
- Parents:
- 1454207
- Location:
- FarmatikoData
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/AdminRepo.cs
r1454207 r6f203af 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using Microsoft.EntityFrameworkCore; 3 4 using System; 4 5 using System.Collections.Generic; … … 17 18 } 18 19 19 public async Task<I Queryable<RequestPharmacyHead>> GetClaimingRequests()20 public async Task<IEnumerable<RequestPharmacyHead>> GetClaimingRequests() 20 21 { 21 var reqs = await Task.Run(() => _context.PHRequests.OrderBy(x => x.Head.Name));22 var reqs = await _context.PHRequests.OrderBy(x => x.Head.Name).ToListAsync(); 22 23 return reqs; 23 24 } 24 25 25 26 //GET 26 public async Task<I Queryable<PharmacyHead>> GetPharmacyHeads()27 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeads() 27 28 { 28 var PHeads = await Task.Run(() => _context.PharmacyHeads.OrderBy(x => x.Name));29 var PHeads = await _context.PharmacyHeads.OrderBy(x => x.Name).ToListAsync(); 29 30 return PHeads; 30 31 } 31 32 //POST 32 public async TaskRemoveClaimRequest(RequestPharmacyHead req)33 public void RemoveClaimRequest(RequestPharmacyHead req) 33 34 { 34 await Task.Run(() => _context.PHRequests.Remove(req));35 await _context.SaveChangesAsync();35 _context.PHRequests.Remove(req); 36 _context.SaveChanges(); 36 37 } 37 38 } -
FarmatikoData/FarmatikoRepo/PHRepo.cs
r1454207 r6f203af 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using System;3 using Microsoft.EntityFrameworkCore; 4 4 using System.Collections.Generic; 5 5 using System.Linq; 6 using System.Text;7 6 using System.Threading.Tasks; 8 7 … … 16 15 _context = context; 17 16 } 18 19 public async Task ClaimPharmacy(RequestPharmacyHead pharmacy)17 //GET 18 public async Task<PharmacyHead> GetPharmacyHeadByIdAsync(int id) 20 19 { 21 await Task.Run(() => _context.PHRequests.Add(pharmacy)); 22 await _context.SaveChangesAsync(); 23 } 24 25 public async Task<PharmacyHead> GetPharmacyHead(PharmacyHead pharmacyHead) 26 { 27 var Phead = await Task.Run(() => _context.PharmacyHeads.Where(x => x.Email.Equals(pharmacyHead.Email)).FirstOrDefault()); 20 var Phead = await _context.PharmacyHeads.Where(x => x.Id == id).FirstOrDefaultAsync(); 28 21 return Phead; 29 22 } 30 23 31 public async Task<I Queryable<PharmacyHead>> GetPharmacyHeadInfo()24 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo() 32 25 { 33 var PHeadInfo = await Task.Run(() => _context.PharmacyHeads.Take(10)); 26 var PHeadInfo = await _context.PharmacyHeads.Take(10).Where(x => x.DeletedOn == null) 27 .Select(x => new PharmacyHead 28 { 29 Id = x.Id, 30 Name = x.Name, 31 Email = x.Email, 32 Password = x.Password, 33 MedicineLists = x.MedicineLists, 34 PharmaciesList = x.PharmaciesList 35 }).ToListAsync(); 34 36 return PHeadInfo; 35 37 } 36 38 //POST 37 39 public async Task UpdatePharmacyHead(PharmacyHead pharmacyHead) 38 40 { 39 var EditedPHead = await Task.Run(() => _context.PharmacyHeads.Where(x => x.Id == pharmacyHead.Id).FirstOrDefault());41 var EditedPHead = await _context.PharmacyHeads.Where(x => x.Id == pharmacyHead.Id).FirstOrDefaultAsync(); 40 42 EditedPHead.Email = pharmacyHead.Email; 41 43 EditedPHead.Name = pharmacyHead.Name; … … 45 47 await _context.SaveChangesAsync(); 46 48 } 49 public async Task ClaimPharmacy(RequestPharmacyHead pharmacy) 50 { 51 await _context.PHRequests.AddAsync(pharmacy); 52 await _context.SaveChangesAsync(); 53 } 54 public async Task Add(PharmacyHead pharmacyHead) 55 { 56 await _context.PharmacyHeads.AddAsync(pharmacyHead); 57 await _context.SaveChangesAsync(); 58 } 59 60 public async Task Remove(PharmacyHead phead) 61 { 62 var Phead = await _context.PharmacyHeads.Where(x => x.Id == phead.Id).FirstOrDefaultAsync(); 63 Phead.DeletedOn = phead.DeletedOn; 64 await _context.SaveChangesAsync(); 65 } 66 67 public async Task RemoveClaimingRequest(int id) 68 { 69 var req = await _context.PHRequests.Where(r => r.Id == id).FirstOrDefaultAsync(); 70 _context.PHRequests.Remove(req); 71 await _context.SaveChangesAsync(); 72 } 47 73 } 48 74 } -
FarmatikoData/FarmatikoRepo/Repository.cs
r1454207 r6f203af 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using Microsoft.EntityFrameworkCore; 4 using System; 5 using System.Collections.Generic; 3 6 using System.Linq; 4 7 using System.Threading.Tasks; … … 14 17 } 15 18 //GET 16 public async Task<I Queryable<HealthcareWorker>> GetAllWorkers()19 public async Task<IEnumerable<HealthcareWorker>> GetAllWorkers() 17 20 { 18 21 var Workers = await Task.Run(() => _context.HealthcareWorkers.Take(10)); … … 20 23 } 21 24 22 public async Task<I Queryable<HealthFacility>> GetFacilities()25 public async Task<IEnumerable<HealthFacility>> GetFacilities() 23 26 { 24 27 var Facilities = await Task.Run(() => _context.HealthFacilities.Take(10)); … … 38 41 } 39 42 40 public async Task<I Queryable<Medicine>> GetMedicines()43 public async Task<IEnumerable<Medicine>> GetMedicines() 41 44 { 42 45 var Medicines = await Task.Run(() => _context.Medicines.Take(10)); … … 50 53 } 51 54 52 public async Task<I Queryable<Pharmacy>> GetPharmacies()55 public async Task<IEnumerable<Pharmacy>> GetPharmacies() 53 56 { 54 57 var Pharmacies = await Task.Run(() => _context.Pharmacies.Take(10)); … … 68 71 } 69 72 70 public async Task<I Queryable<HealthFacility>> SearchFacilities(string query)73 public async Task<IEnumerable<HealthFacility>> SearchFacilities(string query) 71 74 { 72 75 var SearchQuery = await Task.Run(() => _context.HealthFacilities … … 77 80 } 78 81 79 public async Task<I Queryable<Medicine>> SearchMedicines(string query)82 public async Task<IEnumerable<Medicine>> SearchMedicines(string query) 80 83 { 81 84 var SearchQuery = await Task.Run(() => _context.Medicines … … 86 89 } 87 90 88 public async Task<I Queryable<Pharmacy>> SearchPharmacies(string query)91 public async Task<IEnumerable<Pharmacy>> SearchPharmacies(string query) 89 92 { 90 93 var SearchQuery = await Task.Run(() => _context.Pharmacies … … 95 98 } 96 99 97 public async Task<I Queryable<HealthcareWorker>> SearchWorkers(string query)100 public async Task<IEnumerable<HealthcareWorker>> SearchWorkers(string query) 98 101 { 99 102 var SearchQuery = await Task.Run(() => _context.HealthcareWorkers … … 184 187 await _context.SaveChangesAsync(); 185 188 } 186 // ke vidime189 //not impl 187 190 public Task UpdateWorker(HealthcareWorker worker) 188 191 { … … 205 208 } 206 209 207 public async Task RemovePharmacyHead( PharmacyHead pharmacyHead)208 { 209 var PHead = await Task.Run(() => _context.PharmacyHeads.Where(x => x.Id == pharmacyHead.Id).FirstOrDefault());210 PHead.DeletedOn = pharmacyHead.DeletedOn;210 public async Task RemovePharmacyHead(int Id) 211 { 212 var PHead = await _context.PharmacyHeads.Where(x => x.Id == Id).FirstOrDefaultAsync(); 213 PHead.DeletedOn = DateTime.UtcNow; 211 214 await _context.SaveChangesAsync(); 212 215 } -
FarmatikoData/FarmatikoRepoInterfaces/IAdminRepo.cs
r1454207 r6f203af 10 10 public interface IAdminRepo 11 11 { 12 Task<I Queryable<RequestPharmacyHead>> GetClaimingRequests();13 Task<I Queryable<PharmacyHead>> GetPharmacyHeads();14 TaskRemoveClaimRequest(RequestPharmacyHead req);12 Task<IEnumerable<RequestPharmacyHead>> GetClaimingRequests(); 13 Task<IEnumerable<PharmacyHead>> GetPharmacyHeads(); 14 void RemoveClaimRequest(RequestPharmacyHead req); 15 15 } 16 16 } -
FarmatikoData/FarmatikoRepoInterfaces/IPHRepo.cs
r1454207 r6f203af 11 11 { 12 12 Task ClaimPharmacy(RequestPharmacyHead pharmacy); 13 Task<PharmacyHead> GetPharmacyHead(PharmacyHead pharmacyHead); 14 Task<IQueryable<PharmacyHead>> GetPharmacyHeadInfo(); 13 Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo(); 15 14 Task UpdatePharmacyHead(PharmacyHead pharmacyHead); 15 Task<PharmacyHead> GetPharmacyHeadByIdAsync(int id); 16 Task Add(PharmacyHead pharmacyHead); 17 Task Remove(PharmacyHead phead); 18 Task RemoveClaimingRequest(int id); 16 19 } 17 20 } -
FarmatikoData/FarmatikoRepoInterfaces/IRepository.cs
r1454207 r6f203af 11 11 { 12 12 //GET 13 Task<I Queryable<HealthcareWorker>> GetAllWorkers();14 Task<I Queryable<HealthFacility>> GetFacilities();13 Task<IEnumerable<HealthcareWorker>> GetAllWorkers(); 14 Task<IEnumerable<HealthFacility>> GetFacilities(); 15 15 Task<HealthFacility> GetFacility(int Id); 16 16 Task<Medicine> GetMedicine(int Id); 17 Task<I Queryable<Medicine>> GetMedicines();17 Task<IEnumerable<Medicine>> GetMedicines(); 18 18 Task<Pandemic> GetPandemic(); 19 Task<I Queryable<Pharmacy>> GetPharmacies();19 Task<IEnumerable<Pharmacy>> GetPharmacies(); 20 20 Task<Pharmacy> GetPharmacy(int id); 21 21 Task<HealthcareWorker> GetWorker(int id); 22 Task<I Queryable<HealthFacility>> SearchFacilities(string query);23 Task<I Queryable<Medicine>> SearchMedicines(string query);24 Task<I Queryable<Pharmacy>> SearchPharmacies(string query);25 Task<I Queryable<HealthcareWorker>> SearchWorkers(string query);22 Task<IEnumerable<HealthFacility>> SearchFacilities(string query); 23 Task<IEnumerable<Medicine>> SearchMedicines(string query); 24 Task<IEnumerable<Pharmacy>> SearchPharmacies(string query); 25 Task<IEnumerable<HealthcareWorker>> SearchWorkers(string query); 26 26 Task<HealthFacility> GetFacilityJSON(string healthFacility); 27 27 … … 40 40 Task UpadatePharmacy(Pharmacy pharmacy); 41 41 Task UpdateMedicine(Medicine medicine); 42 Task RemovePharmacyHead( PharmacyHead pharmacyHead);42 Task RemovePharmacyHead(int Id); 43 43 } 44 44 }
Note:
See TracChangeset
for help on using the changeset viewer.