public IActionResult Update(int id, [FromBody] GeneralCritereaDto generalCritereaDto) { // map dto to entity and set id var c = _mapper.Map <GeneralCriterea>(generalCritereaDto); c.ID = id; try { // save c = _generalCritereaService.Update(c); for (int i = 0; i < generalCritereaDto.Advices.ToList().Count; i++) { Advice temp = _mapper.Map <Advice>(generalCritereaDto.Advices.ElementAt(i)); _adviceService.Update(temp); } return(Ok(_mapper.Map <GeneralCritereaDto>(c))); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(ex.Message)); } }
public ActionResult UpdateAdvice(Advice advice) { return(Json(adviceService.Update(advice))); }