private void FillFields() { try { List <Item> items = itemRepository.GetItems(); List <EventItem> eventItems = eventItemRepository.GetEventItems(currentEvent.EventID); List <Item> displayedItems = new List <Item>(); List <EventItem> assignedItems = new List <EventItem>(); List <EventItemDetails> testAssignedItems = new List <EventItemDetails>(); foreach (var x in eventItems) { EventItemDetails eventItemDetails = new EventItemDetails(); eventItemDetails.EIDEventItemID = x.EventItemID; if (x.EventID == currentEvent.EventID) { eventItemDetails.EIDEventID = currentEvent.EventID; eventItemDetails.EIDEventDisplayName = currentEvent.EventName; } var currentItem = itemRepository.GetItem(x.ItemID); eventItemDetails.EIDItemID = currentItem.ItemID; eventItemDetails.EIDItemPhrase = currentItem.ItemName; eventItemDetails.EIDItemAssigned = true; testAssignedItems.Add(eventItemDetails); } foreach (var a in items) { bool add = true; foreach (var b in testAssignedItems) { if (b.EIDItemID == a.ItemID) { add = false; } } if (add == true) { displayedItems.Add(a); } } lstCurrentSurveyQuestions.ItemsSource = testAssignedItems; cboAvailableItems.ItemsSource = displayedItems; questionCount = testAssignedItems.Count(); } catch (Exception) { Jeeves.ShowMessage("Error", "Unable to fill the fields"); } }
private void btnDeleteSurveyQuestion_Click(object sender, RoutedEventArgs e) { EventItemDetails selectedEID = new EventItemDetails(); if (lstCurrentSurveyQuestions.SelectedItem != null) { selectedEID = (EventItemDetails)lstCurrentSurveyQuestions.SelectedItem; } try { EventItem eventItem = eventItemRepository.GetEventItem(selectedEID.EIDEventItemID); //make the getEvents more specific by only selecting events that match the ID of the current event eventItemRepository.DeleteEventItem(eventItem); FillFields(); } catch { Jeeves.ShowMessage("Error", "Failure; please try again"); } }
private void FillListOfEventItemDetails() { try { List <Item> items = itemRepository.GetUndeletedItems(); foreach (var x in items) { EventItemDetails newEventItem = new EventItemDetails(); newEventItem.EIDItemID = x.ItemID; newEventItem.EIDItemPhrase = x.ItemName; newEventItem.EIDItemAssigned = false; listOfEventItemsDetails.Add(newEventItem); } } catch (Exception ex) { Jeeves.ShowMessage("Error", ex.GetBaseException().Message.ToString()); } }
private void btnRemoveQuestion_Click(object sender, RoutedEventArgs e) { try { if (lstAvailableSurveyQuestions != null) { EventItemDetails selectedItem = (EventItemDetails)lstSelectedSurveyQuestions.SelectedItem; EventItemDetails changeItem = listOfEventItemsDetails .Where(d => d.EIDItemID == selectedItem.EIDItemID) .FirstOrDefault(); changeItem.EIDItemAssigned = false; questionCount--; FillSurveySelectionLists(); } } catch { Jeeves.ShowMessage("Error", "You need to select a survey question to remove."); } }
private void BuildQuestions() { try { List <Item> surveyItems = itemRepository.GetItems(); List <EventItem> eventQuestions = eventItemRepository.GetEventItems(currentEvent.EventID); foreach (var x in eventQuestions) { SurveyQuestion question = new SurveyQuestion(); questionCount += 1; Item thisItem = surveyItems .Where(c => c.ItemID == x.ItemID) .FirstOrDefault(); question.questPhrase = thisItem.ItemName; question.questDataType = thisItem.ValueType; //Not sure if I still need all this code here - don't delete without testing via commenting out code first var currentEID = new EventItemDetails(); currentEID.EIDEventItemID = x.EventItemID; currentEID.EIDEventID = currentEvent.EventID; currentEID.EIDItemID = x.ItemID; currentEID.EIDItemPhrase = question.questPhrase; currentEID.EIDDataType = question.questDataType; currentEID.EIDquestionCount = questionCount; ListOfEID.Add(currentEID); ShowQuestion(questionCount, question); } } catch { Jeeves.ShowMessage("Error", "There was an error creating the questions."); } }
private void btnAddQuestion_Click(object sender, RoutedEventArgs e) { try { if (lstAvailableSurveyQuestions != null && questionCount < 5) { EventItemDetails selectedItem = (EventItemDetails)lstAvailableSurveyQuestions.SelectedItem; EventItemDetails changeItem = listOfEventItemsDetails .Where(d => d.EIDItemID == selectedItem.EIDItemID) .FirstOrDefault(); changeItem.EIDItemAssigned = true; questionCount++; FillSurveySelectionLists(); } else { Jeeves.ShowMessage("Error", "You are only allowed 5 questions per event"); } } catch { Jeeves.ShowMessage("Error", "You need to select a survey question to add."); } }