[HttpPut("actualizar")] // metodo PUT para actualizar elemento public IActionResult Update([FromBody] ClientMachineDto clientMachineDto) { var clientMachine = _mapper.Map <ClientMachine>(clientMachineDto); // Mapear dto a entitidad try { clientMachine = _clientMachineRepository.Update(clientMachineDto, HttpContext.User.Identity.Name); // Actualizamos el elemento clientMachineDto = _mapper.Map <ClientMachineDto>(clientMachine); // Mapear entitidad a dto return(Ok(clientMachineDto)); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); // Retornar mensaje de error } }
public IActionResult Update([FromBody] ClientMachine model) { if (ModelState.IsValid) { repository.Update(model); return(Ok(model)); } else { return(new ResponseResult(Response) { StatusCode = (int)StatusCodes.Status400BadRequest, ResponseObject = ModelState.ToJson() }.ToJsonResult()); } }