public async Task <SurveyModel> GetAsync(Guid surveyId) { using (var uow = UowProvider.CreateUnitOfWork()) { SurveySections survey = new SurveySections(); var repositorySurveySection = uow.GetRepository <SurveySections, Guid>(); survey = await repositorySurveySection.GetAsync(surveyId); await uow.SaveChangesAsync(); SurveyModel surveyModel = Mapper.Map <SurveySections, SurveyModel>(survey); return(surveyModel); } }
public async Task <bool> SetLockState(Guid id, bool state) { using (var uow = UowProvider.CreateUnitOfWork()) { SurveySections survey = new SurveySections(); var repositorySurveySection = uow.GetRepository <SurveySections, Guid>(); survey = await repositorySurveySection.GetAsync(id); survey.IsLocked = state; survey = repositorySurveySection.Update(survey); await uow.SaveChangesAsync(); return(survey.IsLocked == state); } }
public async Task <Guid> AddAsync(SurveyModel survey) { Guid userId; UsersDto existUser = await _userService.GetAsync(Guid.Parse(NTContext.Context.UserId)); if (existUser == null) { userId = await _userService.AddAsync(Guid.Parse(NTContext.Context.UserId)); } else { userId = existUser.Id; } SurveySectionDto surveyDto = new SurveySectionDto() { Description = survey.Description, Name = survey.Name, DateCreated = System.DateTime.Now, IsShowDescription = survey.IsShowDescription, IsShowProcessCompletedText = survey.IsShowProcessCompletedText, ProcessCompletedText = survey.ProcessCompletedText, UserId = userId, IsOpenAccess = survey.IsOpenAccess, IsLocked = survey.IsLocked }; using (var uow = UowProvider.CreateUnitOfWork()) { SurveySections surveyEntity = Mapper.Map <SurveySectionDto, SurveySections>(surveyDto); var repositorySurveySection = uow.GetRepository <SurveySections, Guid>(); await repositorySurveySection.AddAsync(surveyEntity); await uow.SaveChangesAsync(); return(surveyEntity.Id); } }