public async Task <ActionResult <PharmaceuticalFormDto> > Get([FromRoute] Guid id) { PharmaceuticalFormDto pharmaceuticalForm = _mapper.Map <PharmaceuticalFormDto>(await _pharmaceuticalFormService.GetByIdAsync(id)); if (pharmaceuticalForm == null) { return(NotFound()); } return(Ok(pharmaceuticalForm)); }
public async Task <IActionResult> Put([FromRoute] Guid id, [FromBody] PharmaceuticalFormDto pharmaceuticalForm) { pharmaceuticalForm.Id = id; try { return(Ok(_mapper.Map <PharmaceuticalFormDto>( await _pharmaceuticalFormService.EditAsync(_mapper.Map <PharmaceuticalForm>(pharmaceuticalForm)) ))); } catch (ApiException ex) { return(StatusCode(ex.StatusCode, new { error = true, message = ex.Message })); } }
public async Task <ActionResult <PharmaceuticalFormDto> > Post([FromBody] PharmaceuticalFormCreateDto pharmaceuticalForm) { if (ModelState.IsValid) { try { PharmaceuticalFormDto newPharmaceuticalForm = _mapper.Map <PharmaceuticalFormDto>( await _pharmaceuticalFormService.AddAsync(_mapper.Map <PharmaceuticalForm>(pharmaceuticalForm)) ); return(CreatedAtAction("Get", new { id = newPharmaceuticalForm.Id }, newPharmaceuticalForm)); } catch (ApiException ex) { return(StatusCode(ex.StatusCode, new { error = true, message = ex.Message })); } } return(BadRequest()); }