public async Task <IActionResult> UpdateLab([FromBody] UpdateViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (model.IdLaboratory <= 0) { return(BadRequest()); } try { await _laboratoryService.UpdateLaboratory(model); } catch (DbUpdateException) { if (!(await _laboratoryService.LabExists(model.IdLaboratory))) { return(NotFound()); } else { return(BadRequest()); } } return(Ok()); }
public HttpResponseMessage Update([FromBody] LaboratoryAPIModel laboratoryAPIModel) { if (laboratoryAPIModel == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } if (_laboratoryService.CheckIfLaboratoryExists(laboratoryAPIModel.LabNumber) == true) { _laboratoryService.UpdateLaboratory(_laboratoryAPIMapper.Map(laboratoryAPIModel)); return(Request.CreateResponse(HttpStatusCode.Created, _laboratoryAPIMapper.Map(laboratoryAPIModel))); } else { return(Request.CreateErrorResponse(HttpStatusCode.Conflict, "Laboratory not added yet!")); } }
public void Put([FromBody] LaboratoryModel laboratoryModel) { laboratoryService.UpdateLaboratory(laboratoryModel); }