Changeset d23bf72 for Farmatiko/Controllers
- Timestamp:
- 11/05/20 06:57:35 (4 years ago)
- Branches:
- master
- Children:
- afc9a9a
- Parents:
- 1f4846d
- Location:
- Farmatiko/Controllers
- Files:
-
- 1 added
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/Controllers/AdminController.cs
r1f4846d rd23bf72 5 5 using FarmatikoData.Models; 6 6 using FarmatikoServices.FarmatikoServiceInterfaces; 7 using Microsoft.AspNetCore.Authorization; 7 8 using Microsoft.AspNetCore.Mvc; 8 9 9 10 namespace Farmatiko.Controllers 10 11 { 12 [ApiController] 13 [Authorize(Roles = "PharmacyHead")] 11 14 public class AdminController : Controller 12 15 { … … 40 43 [HttpPost] 41 44 [Route("api/pharmacyhead/add")] 42 public async Task<IActionResult> AddPharmacyHead( PharmacyHead pharmacyHead)45 public async Task<IActionResult> AddPharmacyHead([FromBody]PharmacyHead pharmacyHead) 43 46 { 44 47 await _service.AddPharmacyHead(pharmacyHead); … … 46 49 } 47 50 48 [Http Post]51 [HttpDelete] 49 52 [Route("api/pharmacyhead/delete/{Id}")] 50 public async Task<IActionResult> RemovePharmacyHead([From Query]int Id)53 public async Task<IActionResult> RemovePharmacyHead([FromRoute] int Id) 51 54 { 52 55 await _service.RemovePharmacyHead(Id); 53 56 return Ok(); 54 57 } 55 [HttpPost] 56 public IActionResult RejectRequset(RequestPharmacyHead req) 58 [HttpDelete] 59 [Route("api/pharmacyhead/requests/{Id}")] 60 public IActionResult RejectRequest([FromRoute] int Id) 57 61 { 58 bool Success = _adminService.RejectRequest( req);62 bool Success = _adminService.RejectRequest(Id); 59 63 return Ok(Success); 60 64 } 61 65 [HttpPost] 62 public async Task<IActionResult> ApproveRequest(PharmacyHead pharmacyHead) 66 [Route("api/pharmacyhead/{Id}")] 67 public async Task<IActionResult> ApproveRequest([FromRoute]int Id, [FromBody]PharmacyHead pharmacyHead) 63 68 { 69 int id = Id; 64 70 await _phservice.UpdatePharmacyHead(pharmacyHead); 65 71 return Ok(); -
Farmatiko/Controllers/ErrorController.cs
r1f4846d rd23bf72 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Threading.Tasks; 1 using System.Net; 2 using Microsoft.AspNetCore.Diagnostics; 5 3 using Microsoft.AspNetCore.Mvc; 4 using Microsoft.Extensions.Logging; 6 5 7 6 namespace Farmatiko.Controllers 8 7 { 8 [ApiController] 9 9 public class ErrorController : Controller 10 10 { 11 public IActionResult Index() 11 private readonly ILogger<ErrorController> _logger; 12 13 public ErrorController(ILogger<ErrorController> logger) 12 14 { 13 return View(); 15 _logger = logger; 16 } 17 [Route("/Error")] 18 public IActionResult Error() 19 { 20 var exception = HttpContext.Features.Get<IExceptionHandlerFeature>(); 21 var statusCode = exception.Error.GetType().Name switch 22 { 23 "ArgumentException" => HttpStatusCode.BadRequest, 24 "Exception" => HttpStatusCode.InternalServerError, 25 /*"NotFoundResult" => HttpStatusCode.NotFound,*/ 26 _ => HttpStatusCode.ServiceUnavailable 27 }; 28 _logger.LogInformation(statusCode.ToString() + " " + exception.ToString()); 29 return Problem(detail: exception.Error.Message, statusCode: (int)statusCode); 14 30 } 15 31 } -
Farmatiko/Controllers/FarmatikoController.cs
r1f4846d rd23bf72 11 11 { 12 12 private readonly IService _service; 13 public FarmatikoController(IService service) 13 private readonly IProcessJSONService _JSONservice; 14 public FarmatikoController(IService service, IProcessJSONService JSONservice) 14 15 { 15 16 _service = service; 17 _JSONservice = JSONservice; 16 18 } 17 19 // Workers 18 20 //Get 21 [HttpGet] 22 [Route("api/getData")] 23 public void InsertData() 24 { 25 //_JSONservice.DownloadPharmaciesExcel(); 26 //_JSONservice.GetProcessedHealthcareWorkersFromJSON(); 27 //_JSONservice.GetProcessedHealthFacilitiesFromJSON(); 28 //_JSONservice.GetProcessedMedicinesFromJSON(); 29 //_JSONservice.GetProcessedPandemicsFromJSONApi(); 30 } 19 31 [HttpGet] 20 32 [Route("api/workers")] … … 25 37 } 26 38 [HttpGet] 27 [Route("api/workers/search/{ Query}")]28 public async Task<IEnumerable<HealthcareWorker>> SearchWorkers( string Query)39 [Route("api/workers/search/{query}")] 40 public async Task<IEnumerable<HealthcareWorker>> SearchWorkers([FromRoute]string query) 29 41 { 30 return await _service.SearchWorkers( Query);42 return await _service.SearchWorkers(query); 31 43 } 32 44 [HttpGet] 33 45 [Route("api/workers/{id}")] 34 public async Task<HealthcareWorker> GetWorker( int Id)46 public async Task<HealthcareWorker> GetWorker([FromRoute] int Id) 35 47 { 36 48 return await _service.GetWorker(Id); … … 48 60 } 49 61 [HttpGet] 50 [Route("api/facilities/search/{ Query}")]51 public async Task<IEnumerable<HealthFacility>> SearchFacilities( string Query)62 [Route("api/facilities/search/{query}")] 63 public async Task<IEnumerable<HealthFacility>> SearchFacilities([FromRoute] string query) 52 64 { 53 return await _service.SearchFacilities( Query);65 return await _service.SearchFacilities(query); 54 66 } 55 67 [HttpGet] 56 [Route("api/facilities/{ Id}")]57 public async Task<HealthFacility> GetFacility( int Id)68 [Route("api/facilities/{id}")] 69 public async Task<HealthFacility> GetFacility([FromRoute] int id) 58 70 { 59 return await _service.GetFacility( Id);71 return await _service.GetFacility(id); 60 72 } 61 73 //Post … … 70 82 } 71 83 [HttpGet] 72 [Route("api/medicines/search/{ Query}")]73 public async Task<IEnumerable<Medicine>> SearchMedicines( string Query)84 [Route("api/medicines/search/{query}")] 85 public async Task<IEnumerable<Medicine>> SearchMedicines([FromRoute] string query) 74 86 { 75 return await _service.SearchMedicines( Query);87 return await _service.SearchMedicines(query); 76 88 } 77 89 [HttpGet] 78 90 [Route("api/medicines/{Id}")] 79 public async Task<Medicine> GetMedicine( int Id)91 public async Task<Medicine> GetMedicine([FromRoute] int Id) 80 92 { 81 93 return await _service.GetMedicine(Id); … … 98 110 [HttpGet] 99 111 [Route("api/pharmacy/search/{Query}")] 100 public async Task<IEnumerable<Pharmacy>> SearchPharmacies( string Query)112 public async Task<IEnumerable<Pharmacy>> SearchPharmacies([FromRoute] string Query) 101 113 { 102 114 return await _service.SearchPharmacies(Query); … … 104 116 [HttpGet] 105 117 [Route("api/pharmacy/{Id}")] 106 public async Task<Pharmacy> GetPharmacy( int Id)118 public async Task<Pharmacy> GetPharmacy([FromRoute] int Id) 107 119 { 108 120 return await _service.GetPharmacy(Id); -
Farmatiko/Controllers/PharmacyHeadController.cs
r1f4846d rd23bf72 1 using System.Collections; 2 using System.Collections.Generic; 3 using System.Linq; 1 using System.Collections.Generic; 4 2 using System.Threading.Tasks; 5 using FarmatikoData.FarmatikoRepoInterfaces;6 3 using FarmatikoData.Models; 7 4 using FarmatikoServices.FarmatikoServiceInterfaces; 5 using Microsoft.AspNetCore.Authorization; 8 6 using Microsoft.AspNetCore.Mvc; 9 7 … … 11 9 { 12 10 [ApiController] 11 [Authorize(Roles = "PharmacyHead")] 13 12 public class PharmacyHeadController : Controller 14 13 { … … 20 19 21 20 //GET 22 //Mi trebaat rutite 23 [HttpGet] 21 /*[HttpGet] 24 22 [Route("api/pharmacyhead")] 25 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo( string Token)23 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo() 26 24 { 27 var PHeads = await _PHService.GetPharmacyHeadInfo( Token);25 var PHeads = await _PHService.GetPharmacyHeadInfo(); 28 26 return PHeads; 29 } 27 }*/ 30 28 [HttpGet] 31 29 [Route("api/pharmacyhead/{Id}")] 32 public async Task<PharmacyHead> GetPharmacyHeadById( int Id)30 public async Task<PharmacyHead> GetPharmacyHeadById([FromRoute]int Id) 33 31 { 34 32 var Phead = await _PHService.GetPharmacyHeadByIdAsync(Id); … … 38 36 [HttpPost] 39 37 [Route("api/pharmacyhead/add")] 40 public async Task<IActionResult> AddPharmacyHead( PharmacyHead pharmacyHead)38 public async Task<IActionResult> AddPharmacyHead([FromBody]PharmacyHead pharmacyHead) 41 39 { 42 40 bool Success = await _PHService.Add(pharmacyHead); … … 44 42 } 45 43 46 [HttpPost]44 /*[HttpPost] 47 45 [Route("api/pharmacyhead/login")] 48 46 public async Task<int> Login([FromBody]PharmacyHead pharmacyHead) 49 47 { 50 48 return await _PHService.Login(pharmacyHead); 51 } 49 }*/ 52 50 [HttpPut] 53 51 [Route("api/pharmacyhead/{Id}")] … … 58 56 [HttpPost] 59 57 [Route("api/pharmacyhead/requests")] 60 public async Task<IActionResult> ClaimPharmacy( RequestPharmacyHead pharmacy)58 public async Task<IActionResult> ClaimPharmacy([FromBody]RequestPharmacyHead pharmacy) 61 59 { 62 60 bool Success = await _PHService.ClaimPharmacy(pharmacy); … … 65 63 [HttpDelete] 66 64 [Route("api/pharmacyhead/delete/{Id}")] 67 public async Task<IActionResult> Remove([From Query] int Id)65 public async Task<IActionResult> Remove([FromRoute] int Id) 68 66 { 69 67 bool Success = await _PHService.Remove(Id); … … 72 70 [HttpPost] 73 71 [Route("api/pharmacyhead/requests/{Id}")] 74 public async Task<IActionResult> RemoveClaimingRequest([From Query] int Id)72 public async Task<IActionResult> RemoveClaimingRequest([FromRoute] int Id) 75 73 { 76 74 bool Success = await _PHService.RemoveClaimingRequest(Id);
Note:
See TracChangeset
for help on using the changeset viewer.