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

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

Change methods & add error controller

  • Property mode set to 100644
File size: 2.5 KB
Line 
1using System.Collections;
2using System.Collections.Generic;
3using System.Linq;
4using System.Threading.Tasks;
5using FarmatikoData.FarmatikoRepoInterfaces;
6using FarmatikoData.Models;
7using FarmatikoServices.FarmatikoServiceInterfaces;
8using Microsoft.AspNetCore.Mvc;
9
10namespace Farmatiko.Controllers
11{
12 [ApiController]
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 //Mi trebaat rutite
23 [HttpGet]
24 [Route("api/pharmacyhead")]
25 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo(string Token)
26 {
27 var PHeads = await _PHService.GetPharmacyHeadInfo(Token);
28 return PHeads;
29 }
30 [HttpGet]
31 [Route("api/pharmacyhead/{Id}")]
32 public async Task<PharmacyHead> GetPharmacyHeadById(int Id)
33 {
34 var Phead = await _PHService.GetPharmacyHeadByIdAsync(Id);
35 return Phead;
36 }
37 //POST
38 [HttpPost]
39 [Route("api/pharmacyhead/add")]
40 public async Task<IActionResult> AddPharmacyHead(PharmacyHead pharmacyHead)
41 {
42 bool Success = await _PHService.Add(pharmacyHead);
43 return Ok(Success);
44 }
45
46 [HttpPost]
47 [Route("api/pharmacyhead/login")]
48 public async Task<int> Login([FromBody]PharmacyHead pharmacyHead)
49 {
50 return await _PHService.Login(pharmacyHead);
51 }
52 [HttpPut]
53 [Route("api/pharmacyhead/{Id}")]
54 public async Task UpdatePharmacyHead([FromBody]PharmacyHead pharmacyHead)
55 {
56 await _PHService.UpdatePharmacyHead(pharmacyHead);
57 }
58 [HttpPost]
59 [Route("api/pharmacyhead/requests")]
60 public async Task<IActionResult> ClaimPharmacy(RequestPharmacyHead pharmacy)
61 {
62 bool Success = await _PHService.ClaimPharmacy(pharmacy);
63 return Ok(Success);
64 }
65 [HttpDelete]
66 [Route("api/pharmacyhead/delete/{Id}")]
67 public async Task<IActionResult> Remove([FromQuery] int Id)
68 {
69 bool Success = await _PHService.Remove(Id);
70 return Ok(Success);
71 }
72 [HttpPost]
73 [Route("api/pharmacyhead/requests/{Id}")]
74 public async Task<IActionResult> RemoveClaimingRequest([FromQuery] int Id)
75 {
76 bool Success = await _PHService.RemoveClaimingRequest(Id);
77 return Ok(Success);
78 }
79
80 }
81}
Note: See TracBrowser for help on using the repository browser.