source: Farmatiko/Controllers/AdminController.cs@ 6f203af

Last change on this file since 6f203af was 6f203af, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

Change methods & add error controller

  • Property mode set to 100644
File size: 2.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Threading.Tasks;
5using FarmatikoData.Models;
6using FarmatikoServices.FarmatikoServiceInterfaces;
7using Microsoft.AspNetCore.Mvc;
8
9namespace 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}
Note: See TracBrowser for help on using the repository browser.