source: Farmatiko/Controllers/PharmacyHeadController.cs@ afefe75

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

Update searches, fix bugs

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