Esempio n. 1
0
        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));
            }
        }
Esempio n. 2
0
        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));
            }
        }
Esempio n. 3
0
        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));
            }
        }