public async Task <IQuestionOption> CreateNewOption(Guid questionId, IQuestionOption optionDto) { try { var option = Mappings.Mapper.Map <QuestionOption>(optionDto); option.SurveyQuestionId = questionId; option.Id = Guid.NewGuid(); var persistedEntity = await _optionRepository.Create(option); optionDto.Id = persistedEntity.Id; return(optionDto); } catch (Exception e) { _logger.Error(e, "QuestionOptionManagementService.CreateNewOption"); throw; } }
public async Task <bool> UpdateExistingOption(Guid id, IQuestionOption optionDto) { try { var option = await _optionRepository.Get(id); if (option == null) { return(false); } Mappings.Mapper.Map <IQuestionOption, QuestionOption>(optionDto, option); await _optionRepository.Update(option); return(true); } catch (Exception e) { _logger.Error(e, "QuestionOptionManagementService.UpdateExistingOption"); throw; } }