Last change
on this file since e0cdea2 was e0cdea2, checked in by Dimitar Slezenkovski <dslezenkovski@…>, 4 years ago |
Fix all bugs
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[1454207] | 1 | using FarmatikoData.FarmatikoRepoInterfaces;
|
---|
| 2 | using FarmatikoData.Models;
|
---|
[6f203af] | 3 | using Microsoft.EntityFrameworkCore;
|
---|
[1454207] | 4 | using System;
|
---|
| 5 | using System.Collections.Generic;
|
---|
| 6 | using System.Linq;
|
---|
| 7 | using System.Text;
|
---|
| 8 | using System.Threading.Tasks;
|
---|
| 9 |
|
---|
| 10 | namespace FarmatikoData.FarmatikoRepo
|
---|
| 11 | {
|
---|
| 12 | public class AdminRepo : IAdminRepo
|
---|
| 13 | {
|
---|
| 14 | private readonly FarmatikoDataContext _context;
|
---|
| 15 | public AdminRepo(FarmatikoDataContext context)
|
---|
| 16 | {
|
---|
| 17 | _context = context;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
[6f203af] | 20 | public async Task<IEnumerable<RequestPharmacyHead>> GetClaimingRequests()
|
---|
[1454207] | 21 | {
|
---|
[e0cdea2] | 22 | var reqs = await _context.PHRequests.Select(x => new RequestPharmacyHead
|
---|
| 23 | {
|
---|
| 24 | Head = x.Head,
|
---|
| 25 | Pharmacy = x.Pharmacy
|
---|
| 26 | }).OrderBy(x => x.Head.Name).ToListAsync();
|
---|
[1454207] | 27 | return reqs;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | //GET
|
---|
[6f203af] | 31 | public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeads()
|
---|
[1454207] | 32 | {
|
---|
[db484c9] | 33 | var PHeads = await _context.PharmacyHeads
|
---|
| 34 | .Include(x => x.Medicines)
|
---|
| 35 | .Include(x => x.Pharmacies)
|
---|
| 36 | .OrderBy(x => x.Name)
|
---|
| 37 | .ToListAsync();
|
---|
[1454207] | 38 | return PHeads;
|
---|
| 39 | }
|
---|
| 40 | //POST
|
---|
[e0cdea2] | 41 | public void RemoveClaimRequest(RequestPharmacyHead request)
|
---|
[1454207] | 42 | {
|
---|
[e0cdea2] | 43 | var req = _context.PHRequests.Select(x => new RequestPharmacyHead { Head = x.Head, Pharmacy = x.Pharmacy, Id = x.Id})
|
---|
| 44 | .Where(x => x.Head.Email.Equals(request.Head.Email)).FirstOrDefault();
|
---|
[6f203af] | 45 | _context.PHRequests.Remove(req);
|
---|
[e0cdea2] | 46 | _context.SaveChanges();
|
---|
[1454207] | 47 | }
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.