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 | [Route("api/pharmacyhead")]
|
---|
26 | public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeads()
|
---|
27 | {
|
---|
28 | return await _adminService.GetPharmacyHeads();
|
---|
29 | }
|
---|
30 |
|
---|
31 | [HttpGet]
|
---|
32 | [Route("api/pharmacyhead/requests")]
|
---|
33 | public async Task<IEnumerable<RequestPharmacyHead>> GetClaimingRequests()
|
---|
34 | {
|
---|
35 | return await _adminService.GetClaimingRequests();
|
---|
36 | }
|
---|
37 |
|
---|
38 |
|
---|
39 | //POST
|
---|
40 | [HttpPost]
|
---|
41 | [Route("api/pharmacyhead/add")]
|
---|
42 | public async Task<IActionResult> AddPharmacyHead(PharmacyHead pharmacyHead)
|
---|
43 | {
|
---|
44 | await _service.AddPharmacyHead(pharmacyHead);
|
---|
45 | return Ok();
|
---|
46 | }
|
---|
47 |
|
---|
48 | [HttpPost]
|
---|
49 | [Route("api/pharmacyhead/delete/{Id}")]
|
---|
50 | public async Task<IActionResult> RemovePharmacyHead([FromQuery]int Id)
|
---|
51 | {
|
---|
52 | await _service.RemovePharmacyHead(Id);
|
---|
53 | return Ok();
|
---|
54 | }
|
---|
55 | [HttpPost]
|
---|
56 | public IActionResult RejectRequset(RequestPharmacyHead req)
|
---|
57 | {
|
---|
58 | bool Success = _adminService.RejectRequest(req);
|
---|
59 | return Ok(Success);
|
---|
60 | }
|
---|
61 | [HttpPost]
|
---|
62 | public async Task<IActionResult> ApproveRequest(PharmacyHead pharmacyHead)
|
---|
63 | {
|
---|
64 | await _phservice.UpdatePharmacyHead(pharmacyHead);
|
---|
65 | return Ok();
|
---|
66 | }
|
---|
67 |
|
---|
68 | }
|
---|
69 | }
|
---|