public async Task <IActionResult> UpdateMedicineAsync( Guid id, [FromBody] CreateMedicineCommand command) { try { await medicineService.Update( id, command.CommercialName, command.RegistrationCode, command.IsPrescriptionMedicine, command.IngredientConcentration, command.PackingSpecification, command.DosageForm, command.DeclaredPrice, command.CurrentlyLoggedInTenant, command.Certificates, command.IsApprovedByAdmin); return(Ok()); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex)); } }
public async Task <IActionResult> CreateMedicineAsync( [FromBody] CreateMedicineCommand command) { try { if (command.DeclaredPrice <= 0) { return(BadRequest("Declared Price cannot be less than 0.")); } if (!string.IsNullOrEmpty(command.Certificates)) { // Ensure each certificate provided in the command List <string> certificateList = command.Certificates.Split(',').ToList(); foreach (var cert in certificateList) { if (string.IsNullOrEmpty(uploadService.GetFileUri(cert))) { return(BadRequest("At least one certificate name provided is not valid.")); } } } //var test = User.Claims.FirstOrDefault(); //string userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; //var client = new ManagementApiClient(auth0Service.ObtainAccessToken(), new Uri("https://pharmachain.au.auth0.com/api/v2/")); var result = await medicineService.Create( command.CommercialName, command.RegistrationCode, command.IsPrescriptionMedicine, command.DosageForm, command.IngredientConcentration, command.PackingSpecification, command.DeclaredPrice, command.CurrentlyLoggedInTenant, command.Certificates); return(Ok(new { MedicineId = result })); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex)); } }