[6f203af] | 1 | using System.Collections;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
[1454207] | 4 | using System.Threading.Tasks;
|
---|
[4e72684] | 5 | using FarmatikoData.FarmatikoRepoInterfaces;
|
---|
| 6 | using FarmatikoData.Models;
|
---|
[1454207] | 7 | using FarmatikoServices.FarmatikoServiceInterfaces;
|
---|
[4e72684] | 8 | using Microsoft.AspNetCore.Mvc;
|
---|
| 9 |
|
---|
| 10 | namespace Farmatiko.Controllers
|
---|
| 11 | {
|
---|
| 12 | [ApiController]
|
---|
| 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
|
---|
| 22 | //Mi trebaat rutite
|
---|
[4e72684] | 23 | [HttpGet]
|
---|
[6f203af] | 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)
|
---|
[4e72684] | 33 | {
|
---|
[6f203af] | 34 | var Phead = await _PHService.GetPharmacyHeadByIdAsync(Id);
|
---|
| 35 | return Phead;
|
---|
[4e72684] | 36 | }
|
---|
[1454207] | 37 | //POST
|
---|
| 38 | [HttpPost]
|
---|
[6f203af] | 39 | [Route("api/pharmacyhead/add")]
|
---|
| 40 | public async Task<IActionResult> AddPharmacyHead(PharmacyHead pharmacyHead)
|
---|
[a55ef91] | 41 | {
|
---|
[6f203af] | 42 | bool Success = await _PHService.Add(pharmacyHead);
|
---|
| 43 | return Ok(Success);
|
---|
[a55ef91] | 44 | }
|
---|
[6f203af] | 45 |
|
---|
[a55ef91] | 46 | [HttpPost]
|
---|
[6f203af] | 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)
|
---|
[a55ef91] | 55 | {
|
---|
[1454207] | 56 | await _PHService.UpdatePharmacyHead(pharmacyHead);
|
---|
[a55ef91] | 57 | }
|
---|
| 58 | [HttpPost]
|
---|
[6f203af] | 59 | [Route("api/pharmacyhead/requests")]
|
---|
[1454207] | 60 | public async Task<IActionResult> ClaimPharmacy(RequestPharmacyHead pharmacy)
|
---|
[a55ef91] | 61 | {
|
---|
[6f203af] | 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);
|
---|
[a55ef91] | 78 | }
|
---|
[1454207] | 79 |
|
---|
[4e72684] | 80 | }
|
---|
| 81 | }
|
---|