source: Farmatiko/Controllers/PharmacyHeadController.cs@ afefe75

Last change on this file since afefe75 was afefe75, checked in by Dimitar Slezenkovski <dslezenkovski@…>, 4 years ago

Update searches, fix bugs

  • Property mode set to 100644
File size: 1.9 KB
Line 
1using System.Collections.Generic;
2using System.Threading.Tasks;
3using FarmatikoData.DTOs;
4using FarmatikoData.Models;
5using FarmatikoServices.FarmatikoServiceInterfaces;
6using Microsoft.AspNetCore.Authorization;
7using Microsoft.AspNetCore.Mvc;
8
9namespace Farmatiko.Controllers
10{
11 [ApiController]
12 [Authorize(Roles = "PharmacyHead,Admin")]
13 public class PharmacyHeadController : Controller
14 {
15 private readonly IPHService _PHService;
16 public PharmacyHeadController(IPHService PHService)
17 {
18 _PHService = PHService;
19 }
20
21 //GET
22
23 [HttpGet]
24 [Route("api/pharmacyhead/{Id}")]
25 public async Task<PharmacyHead> GetPharmacyHeadById([FromRoute] int Id)
26 {
27 var Phead = await _PHService.GetPharmacyHeadByIdAsync(Id);
28 return Phead;
29 }
30 //POST
31
32 [HttpPost]
33 [Route("api/pharmacyhead/update")]
34 public async Task<IActionResult> UpdatePharmacyHead([FromBody] PharmacyHeadDto pharmacyHead)
35 {
36 await _PHService.UpdatePharmacyHead(pharmacyHead);
37 return Ok();
38 }
39 [HttpPost]
40 [Route("api/pharmacyhead/requests")]
41 public async Task<IActionResult> ClaimPharmacy([FromBody] RequestPharmacyHead pharmacy)
42 {
43 bool Success = await _PHService.ClaimPharmacy(pharmacy);
44 return Ok(Success);
45 }
46 [HttpDelete]
47 [Route("api/pharmacyhead/delete/{Id}")]
48 public async Task<IActionResult> Remove([FromRoute] int Id)
49 {
50 bool Success = await _PHService.Remove(Id);
51 return Ok(Success);
52 }
53 [HttpPost]
54 [Route("api/pharmacyhead/requests/{Id}")]
55 public async Task<IActionResult> RemoveClaimingRequest([FromRoute] int Id)
56 {
57 bool Success = await _PHService.RemoveClaimingRequest(Id);
58 return Ok(Success);
59 }
60
61 }
62}
Note: See TracBrowser for help on using the repository browser.