public async Task <OperationResult> Create(SurveyConfigCreateModel createModel) { try { var core = await _coreHelper.GetCore(); await using var sdkContext = core.DbContextHelper.GetDbContext(); var surveyConfig = new SurveyConfiguration() { QuestionSetId = createModel.SurveyId, }; await surveyConfig.Create(sdkContext); foreach (var locationsId in createModel.LocationsIds) { var siteSurveyConfig = new SiteSurveyConfiguration() { SurveyConfigurationId = surveyConfig.Id, SiteId = locationsId, }; await siteSurveyConfig.Create(sdkContext); } return(new OperationResult( true, _localizationService.GetString("SurveyConfigurationCreatedSuccessfully"))); } catch (Exception e) { Trace.TraceError(e.Message); _logger.LogError(e.Message); return(new OperationResult( false, _localizationService.GetString("ErrorWhileCreatingSurveyConfiguration"))); } }
public async Task <OperationResult> Create([FromBody] SurveyConfigCreateModel createModel) { return(await _surveysService.Create(createModel)); }