public IActionResult Create([FromBody] AnwserDto anwserDto) { // map dto to entity and set id Anwser c = _mapper.Map <Anwser>(anwserDto); try { // save c = _anwserService.Create(c); return(Ok(_mapper.Map <AnwserDto>(c))); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(ex.Message)); } }
public IActionResult UpdateCompletion(int id, string completion, [FromBody] AnwserDto anwserDto) { // map dto to entity and set id var c = _mapper.Map <Anwser>(anwserDto); c.ID = id; try { c = _anwserService.UpdateCompletion(c, completion); return(Ok(_mapper.Map <AnwserDto>(c))); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(ex.Message)); } }
public IActionResult Update(int id, [FromBody] AnwserDto anwserDto) { // map dto to entity and set id var c = _mapper.Map <Anwser>(anwserDto); c.ID = id; try { // save c = _anwserService.Update(c); _examAttemptService.recalculateSimple(c.ExamAttemptID); return(Ok(_mapper.Map <AnwserDto>(c))); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(ex.Message)); } }