source: FarmatikoData/FarmatikoRepo/AdminRepo.cs@ 472dd7e

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 
1using FarmatikoData.FarmatikoRepoInterfaces;
2using FarmatikoData.Models;
3using Microsoft.EntityFrameworkCore;
4using System;
5using System.Collections.Generic;
6using System.Linq;
7using System.Text;
8using System.Threading.Tasks;
9
10namespace 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.