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