Example #1
0
        public IActionResult Create([FromBody] UserPollAnswerDto userPollAnswerDto)
        {
            var userPollAnswer = _mapper.Map <UserPollAnswer>(userPollAnswerDto);

            try
            {
                _userPollAnswerService.Create(userPollAnswer);
                return(Ok());
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Example #2
0
        public IActionResult Update(int id, [FromBody] UserPollAnswerDto userPollAnswerDto)
        {
            // map dto to entity and set id
            var userPollAnswer = _mapper.Map <UserPollAnswer>(userPollAnswerDto);

            userPollAnswer.Id = id;

            try
            {
                // save
                _userPollAnswerService.Update(userPollAnswer);
                return(Ok());
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }