public ResponseSet CreateNewResponseSetWithAnswers(System.Collections.Generic.IEnumerable<DataAccessModels.Category> categories, int surveyID, string responseSetName) { var responseSet = new ResponseSet { DateSaved = DateTime.Now, IsSubmitted = false, SurveyID = surveyID, UserID = Membership.CurrentUser.ID, SystemID = GenerateUniqueID(), Name = responseSetName, IsCompleted = false, Progress = 0, }; using (var responseSetRepository = new ResponseSetRepository()) { responseSetRepository.AddResponseSetToDB(responseSet); } return UpdateResponseSetWithAnswers(categories, responseSet.ID); }
partial void DeleteResponseSet(ResponseSet instance);
private void DeleteResponseSetExecute(ResponseSet selectedResponseSet) { this.BusyCount++; bool isDeleted = this.responseRepository.DeleteResponseSet(selectedResponseSet.ID); if (isDeleted) { IEnumerable<ResponseSet> top = null; IEnumerable<ResponseSet> all = null; switch (this.currentType) { case ResponseSetsType.Saved: top = this.responseRepository.GetTopSavedResponseSetsForUser(Membership.CurrentUser.ID, TOP_COUNT); all = this.responseRepository.GetSavedResponseSetsForUser(Membership.CurrentUser.ID); break; case ResponseSetsType.Submitted: top = this.responseRepository.GetTopSubmittedResponseSetsForUser(Membership.CurrentUser.ID, TOP_COUNT); all = this.responseRepository.GetSubmittedResponseSetsForUser(Membership.CurrentUser.ID); break; } if (Locator.SurveyDetailsStatic.CurrentSurvey != null && Locator.SurveyDetailsStatic.CurrentSurvey.ID != 0 && Locator.SurveyDetailsStatic.CurrentSurvey.ID == selectedResponseSet.SurveyID) { Locator.SurveyDetailsStatic.Refresh(); } this.TopResponses = new ObservableCollection<ResponseSet>(top); this.allResponses = new ObservableCollection<ResponseSet>(all); this.DisplayedResponses = this.allResponses; #if !UNIT_TEST MessageBox.Show((Application.Current.Resources["LanguageStrings"] as LanguageStrings).RESPOSE_DELETED); #else RaiseTestCompleted("RESPONSE_DELETED"); #endif } else { MessageBox.Show((Application.Current.Resources["LanguageStrings"] as LanguageStrings).ERROR_RESPONSE_DELETE); } Locator.NavigationStatic.NavigateToQuestionsCommand.RaiseCanExecuteChanged(); this.BusyCount--; }
partial void UpdateResponseSet(ResponseSet instance);
partial void InsertResponseSet(ResponseSet instance);
private void detach_ResponseSet(ResponseSet entity) { this.SendPropertyChanging(); entity.User = null; }
private void attach_ResponseSet(ResponseSet entity) { this.SendPropertyChanging(); entity.User = this; }
public static ResponseSet GenerateResponseSet(ResponseSetType type, Survey survey) { ResponseSet set = new ResponseSet(); set.ID = rand.Next(0, 1000); set.SurveyID = survey.ID; set.SystemID = LoginViewModelTest.SERVER_PATH; set.Name = rand.Next(0, 1000).ToString(); switch (type) { case ResponseSetType.Completed: set.IsCompleted = true; break; case ResponseSetType.InProgress: set.IsCompleted = false; set.IsSubmitted = false; break; case ResponseSetType.Submitted: set.IsSubmitted = true; break; default: break; } set.UserID = Membership.CurrentUser.ID; return set; }