1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Threading.Tasks;
|
---|
5 | using FarmatikoData.Models;
|
---|
6 | using FarmatikoServices.FarmatikoServiceInterfaces;
|
---|
7 | using Microsoft.AspNetCore.Mvc;
|
---|
8 |
|
---|
9 | namespace Farmatiko.Controllers
|
---|
10 | {
|
---|
11 | public class AdminController : Controller
|
---|
12 | {
|
---|
13 | private readonly IAdminService _adminService;
|
---|
14 | private readonly IService _service;
|
---|
15 | private readonly IPHService _phservice;
|
---|
16 | public AdminController(IAdminService adminService, IService service, IPHService phservice)
|
---|
17 | {
|
---|
18 | _adminService = adminService;
|
---|
19 | _service = service;
|
---|
20 | _phservice = phservice;
|
---|
21 | }
|
---|
22 |
|
---|
23 | //GET
|
---|
24 | [HttpGet]
|
---|
25 | public async Task<IQueryable<PharmacyHead>> GetPharmacyHeads()
|
---|
26 | {
|
---|
27 | return await _adminService.GetPharmacyHeads();
|
---|
28 | }
|
---|
29 |
|
---|
30 | [HttpGet]
|
---|
31 | public async Task<IQueryable<RequestPharmacyHead>> GetClaimingRequests()
|
---|
32 | {
|
---|
33 | return await _adminService.GetCalimingRequests();
|
---|
34 | }
|
---|
35 |
|
---|
36 |
|
---|
37 | //POST
|
---|
38 | [HttpPost]
|
---|
39 | public async Task<IActionResult> AddPharmacyHead(PharmacyHead pharmacyHead)
|
---|
40 | {
|
---|
41 | await _service.AddPharmacyHead(pharmacyHead);
|
---|
42 | return Ok();
|
---|
43 | }
|
---|
44 |
|
---|
45 | [HttpPost]
|
---|
46 | public async Task<IActionResult> RemovePharmacyHead(PharmacyHead pharmacyHead)
|
---|
47 | {
|
---|
48 | await _service.RemovePharmacyHead(pharmacyHead);
|
---|
49 | return Ok();
|
---|
50 | }
|
---|
51 | [HttpPost]
|
---|
52 | public async Task<IActionResult> RejectRequset(RequestPharmacyHead req)
|
---|
53 | {
|
---|
54 | await _adminService.RejectRequest(req);
|
---|
55 | return Ok();
|
---|
56 | }
|
---|
57 | [HttpPost]
|
---|
58 | public async Task<IActionResult> ApproveRequest(PharmacyHead pharmacyHead)
|
---|
59 | {
|
---|
60 | await _phservice.UpdatePharmacyHead(pharmacyHead);
|
---|
61 | return Ok();
|
---|
62 | }
|
---|
63 |
|
---|
64 | }
|
---|
65 | }
|
---|