Last change
on this file since 472dd7e was e0cdea2, checked in by Dimitar Slezenkovski <dslezenkovski@…>, 4 years ago |
Fix all bugs
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | using FarmatikoData.FarmatikoRepoInterfaces;
|
---|
2 | using FarmatikoData.Models;
|
---|
3 | using Microsoft.EntityFrameworkCore;
|
---|
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 |
|
---|
20 | public async Task<IEnumerable<RequestPharmacyHead>> GetClaimingRequests()
|
---|
21 | {
|
---|
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();
|
---|
27 | return reqs;
|
---|
28 | }
|
---|
29 |
|
---|
30 | //GET
|
---|
31 | public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeads()
|
---|
32 | {
|
---|
33 | var PHeads = await _context.PharmacyHeads
|
---|
34 | .Include(x => x.Medicines)
|
---|
35 | .Include(x => x.Pharmacies)
|
---|
36 | .OrderBy(x => x.Name)
|
---|
37 | .ToListAsync();
|
---|
38 | return PHeads;
|
---|
39 | }
|
---|
40 | //POST
|
---|
41 | public void RemoveClaimRequest(RequestPharmacyHead request)
|
---|
42 | {
|
---|
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();
|
---|
45 | _context.PHRequests.Remove(req);
|
---|
46 | _context.SaveChanges();
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.