Пример #1
0
        // Get Skills
        public async Task <List <Skill> > GetSkills()
        {
            var response = await client.GetAsync("api/Skills");

            if (response.IsSuccessStatusCode)
            {
                List <Skill> skills = await response.Content.ReadAsAsync <List <Skill> >();

                return(skills);
            }
            else
            {
                var ex = Jeeves.CreateApiException(response);
                throw ex;
            }
        }
Пример #2
0
        public async Task <List <Province> > GetProvinces()
        {
            var response = await client.GetAsync("api/provinces");

            if (response.IsSuccessStatusCode)
            {
                List <Province> provinces = await response.Content.ReadAsAsync <List <Province> >();

                return(provinces);
            }
            else
            {
                var ex = Jeeves.CreateApiException(response);
                throw ex;
            }
        }
Пример #3
0
        // Get CharacterByClass
        public async Task <List <Skill> > GetSkillByClass(int ClassID)
        {
            var response = await client.GetAsync($"api/Skills/ByClass/{ClassID}");

            if (response.IsSuccessStatusCode)
            {
                List <Skill> skill = await response.Content.ReadAsAsync <List <Skill> >();

                return(skill);
            }
            else
            {
                var ex = Jeeves.CreateApiException(response);
                throw ex;
            }
        }
Пример #4
0
        /// <summary>
        /// Method to create a list of all Users in database
        /// </summary>
        private void FillUserList()
        {
            try
            {
                //get users
                List <Users> users = usersRepository.GetUsers();

                //set source for the ListView to the list of users
                lvUsers.ItemsSource = users;
            }
            catch (Exception e)
            {
                //could not get list of users
                Jeeves.ShowMessage("Error", e.Message.ToString());
            }
        }
Пример #5
0
        // Get CharacterByClass
        public async Task <List <Character> > GetCharactersByClass(int ClassID)
        {
            var response = await client.GetAsync($"api/Characters/ByClass/{ClassID}");

            if (response.IsSuccessStatusCode)
            {
                List <Character> character = await response.Content.ReadAsAsync <List <Character> >();

                return(character);
            }
            else
            {
                var ex = Jeeves.CreateApiException(response);
                throw ex;
            }
        }
Пример #6
0
        // Get ClassType
        public async Task <ClassType> GetClassType(int ID)
        {
            var response = await client.GetAsync($"api/Types/{ID}");

            if (response.IsSuccessStatusCode)
            {
                ClassType classType = await response.Content.ReadAsAsync <ClassType>();

                return(classType);
            }
            else
            {
                var ex = Jeeves.CreateApiException(response);
                throw ex;
            }
        }
Пример #7
0
 private void btnChooseWinner_Click(object sender, RoutedEventArgs e)
 {
     if (gdvEditEvents.SelectedItem != null)
     {
         var selectedEvent = gdvEditEvents.SelectedItem;
         Frame.Navigate(typeof(EventWinner), (Models.Event)selectedEvent);
     }
     else if (gdvDeleteEvents.SelectedItem != null)
     {
         var selectedEvent = gdvEditEvents.SelectedItem;
         Frame.Navigate(typeof(EventWinner), (Models.Event)selectedEvent);
     }
     else
     {
         Jeeves.ShowMessage("Error", "Please select an event first");
     }
 }
Пример #8
0
        private bool CheckForProperDateUsage()
        {
            var eventStart = Convert.ToDateTime(eventStartDate.Date.ToString());
            var eventEnd   = Convert.ToDateTime(cdpEventEnd.Date.ToString());

            if (eventStart > eventEnd)
            {
                Jeeves.ShowMessage("Error", "Please choose an end date that is after the start date");
                return(false);
            }
            else if (eventStart < (DateTime.Now.AddDays(-2)))
            {
                Jeeves.ShowMessage("Error", "Please choose a start date in the future");
                return(false);
            }
            return(true);
        }
Пример #9
0
        // Get Character
        public async Task <Character> GetCharacter(int ID)
        {
            var response = await client.GetAsync($"api/Characters/{ID}");

            if (response.IsSuccessStatusCode)
            {
                Character character = await response.Content.ReadAsAsync <Character>();

                character.Race.ToString();
                return(character);
            }
            else
            {
                var ex = Jeeves.CreateApiException(response);
                throw ex;
            }
        }
Пример #10
0
 private void btnRegisterAttendance_Click(object sender, RoutedEventArgs e)
 {
     if (gdvEditEvents.SelectedItem != null)
     {
         Event selectedEvent = (Event)gdvEditEvents.SelectedItem;
         Frame.Navigate(typeof(EventAttendanceTracking), (Event)selectedEvent, new SuppressNavigationTransitionInfo());
     }
     else if (gdvDeleteEvents.SelectedItem != null)
     {
         Event selectedEvent = (Event)gdvDeleteEvents.SelectedItem;
         Frame.Navigate(typeof(EventAttendanceTracking), (Event)selectedEvent, new SuppressNavigationTransitionInfo());
     }
     else
     {
         Jeeves.ShowMessage("Error", "Please select an active event");
     }
 }
Пример #11
0
        private void SaveQuestion(Item selectedItem)
        {
            try
            {
                selectedItem.ItemName = txtNewSurveyQuestion.Text;
                DataType selectedDataType = (DataType)cboDataType.SelectedItem;

                selectedItem.ValueType = selectedDataType.DisplayText;
                itemRespository.UpdateItem(selectedItem);

                ScreenUnlock();
                ClearFields();
            }
            catch
            {
                Jeeves.ShowMessage("Error", "Unable to save the question");
            }
            FillFields();
        }
        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 CheckForSelectedQuiz()
 {
     if (view.QuizID == null)
     {
         tbChosenQuiz.Text = "Selected Quiz: None";
     }
     else
     {
         try
         {
             var quiz = gameRepository.GetAGame((int)view.QuizID);
             tbChosenQuiz.Text = "Selected Quiz: " + quiz.Title;
         }
         catch
         {
             Jeeves.ShowMessage("Error", "The quiz failed to load");
         }
     }
 }
Пример #14
0
        private bool BuildNamesForTheEvent()
        {
            string[] eventNameArray = eventNameTextBox.Text.Trim().Split(' ');

            string tempEventNameString = "";

            for (int x = 0; x < eventNameArray.Length; x++)
            {
                if (eventNameArray[x] != "")
                {
                    tempEventNameString += eventNameArray[x].Substring(0, 1).ToUpper() + eventNameArray[x].Substring(1).ToLower() + " ";
                }
            }
            tempEventNameString = tempEventNameString.Trim();

            var startString = string.Format("{0:yyyy-MM-dd}", view.EventStart);

            if (tempEventNameString.Substring(tempEventNameString.Length - 4) != startString.Substring(0, 4))
            {
                tempEventNameString += " " + startString.Substring(0, 4);
            }
            view.DisplayName = tempEventNameString;

            string[] eventDisplayNameArray = tempEventNameString.Split(' ');
            view.EventName = string.Join("", eventDisplayNameArray);

            string eventAbbreviateName = "";

            foreach (string x in eventDisplayNameArray)
            {
                eventAbbreviateName += x.Substring(0, 1).ToUpper();
            }
            eventAbbreviateName  = eventAbbreviateName.Remove(eventAbbreviateName.Length - 1, 1);
            eventAbbreviateName += startString.Substring(5, 2) + startString.Substring(0, 4);
            if (eventAbbreviateName.Length > 20)
            {
                Jeeves.ShowMessage("Error", "Please reduce the number of words or hyphens in your event name");
                return(false);
            }
            view.AbrevEventname = eventAbbreviateName;
            return(true);
        }
        private void BtnConfirmRemove_Tapped(object sender, TappedRoutedEventArgs e)
        {
            try
            {
                string selected         = Convert.ToString(((Button)sender).DataContext);
                Item   thisSelectedItem = itemRespository.GetItem(selected.ToString());

                App userInfo = (App)Application.Current;
                thisSelectedItem.IsDeleted        = true;
                thisSelectedItem.LastModifiedBy   = userInfo.userAccountName;
                thisSelectedItem.LastModifiedDate = DateTime.Now;
                itemRespository.DeleteUpdateItem(thisSelectedItem);
                NewAuditLine("Modified(Delete) by:" + userInfo.userAccountName + ", SurveyItem:" + thisSelectedItem.ItemID + " " + thisSelectedItem.ItemName + ", On Date: " + thisSelectedItem.LastModifiedDate.ToString());
                Frame.Navigate(typeof(Surveys), deleteMode, new SuppressNavigationTransitionInfo());
            }
            catch
            {
                Jeeves.ShowMessage("Error", "Problem with deleting the survey question");
            }
        }
Пример #16
0
        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 bool CheckFormForCompletion()
        {
            bool formFilledIn = true;

            if (memberNumTextBox.Text.Trim() == "")
            {
                if (firstNameTextBox.Text.Trim() == "" || lastNameTextBox.Text.Trim() == "")
                {
                    formFilledIn = false;
                }
            }

            if (formFilledIn == false)
            {
                Jeeves.ShowMessage("Error", "You must fill in either the member number or a first and last name");
                return(false);
            }

            return(formFilledIn);
        }
Пример #18
0
        private bool AddEventDatesAndTimes()
        {
            string[] startDate = eventStartDate.Date.ToString().Split(" ");
            var      startTime = tpEventStart.Time.ToString();
            DateTime start     = Convert.ToDateTime(startDate[0] + " " + startTime);

            string[] endDate = cdpEventEnd.Date.ToString().Split(" ");
            var      endTime = tpEventEnd.Time.ToString();
            DateTime end     = Convert.ToDateTime(endDate[0] + " " + endTime);

            if (start > end)
            {
                Jeeves.ShowMessage("Error", "Please set a start date/time that is before the end date/time");
                return(false);
            }

            view.EventStart = start;
            view.EventEnd   = end;
            return(true);
        }
Пример #19
0
 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.");
     }
 }
Пример #20
0
        private async void fillDropDown()
        {
            ArtTypeRepository r = new ArtTypeRepository();

            try
            {
                List <ArtType> artTypes = await r.GetArtType();

                //Add the All Option
                artTypes.Add(new ArtType {
                    ID = 0, Type = " - All Art Types"
                });
                //Save them for the Patient Details
                App thisApp = Application.Current as App;
                thisApp.allTypes = artTypes;
                //Bind to the ComboBox
                ArtTypeCombo.ItemsSource = artTypes.OrderBy(at => at.Type);
            }

            catch (ApiException apiEx)
            {
                var sb = new StringBuilder();
                sb.AppendLine("Errors:");
                foreach (var error in apiEx.Errors)
                {
                    sb.AppendLine("-" + error);
                }
                Jeeves.ShowMessage("Could not complete operation:", sb.ToString());
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message.Contains("connection with the server"))
                {
                    Jeeves.ShowMessage("Error", "No connection with the server. Check that the Web Service is running and available and then click the Refresh button.");
                }
                else
                {
                    Jeeves.ShowMessage("Error", "Could not complete operation.");
                }
            }
        }
Пример #21
0
        private async void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            string strTitle            = "Confirm Delete";
            string strMsg              = "Are you certain that you want to delete " + view.Name + "?";
            ContentDialogResult result = await Jeeves.ConfirmDialog(strTitle, strMsg);

            if (result == ContentDialogResult.Secondary)
            {
                try
                {
                    view.ArtType = null;
                    ArtWorkRepository er = new ArtWorkRepository();
                    await er.DeleteArtWork(view);

                    Frame.GoBack();
                }
                catch (AggregateException ex)
                {
                    string errMsg = "";
                    foreach (var exception in ex.InnerExceptions)
                    {
                        errMsg += Environment.NewLine + exception.Message;
                    }
                    Jeeves.ShowMessage("One or more exceptions has occurred:", errMsg);
                }
                catch (ApiException apiEx)
                {
                    var sb = new StringBuilder();
                    sb.AppendLine("Errors:");
                    foreach (var error in apiEx.Errors)
                    {
                        sb.AppendLine("-" + error);
                    }
                    Jeeves.ShowMessage("Problem Deleting the Patient:", sb.ToString());
                }
                catch (Exception)
                {
                    Jeeves.ShowMessage("Error", "Error Deleting Patient");
                }
            }
        }
        private void btnNextQuestion_Click(object sender, RoutedEventArgs e)
        {
            var choosenAnswer = new Answer();

            if (gvDisplayAnswers.SelectedItem != null)
            {
                choosenAnswer = (Answer)gvDisplayAnswers.SelectedItem;

                if (choosenAnswer.IsCorrect == true)
                {
                    Jeeves.ShowMessage("Correct", "Your answer was correct!");
                }
                else
                {
                    Jeeves.ShowMessage("Incorrect", "Your answer was wrong");
                }

                SaveQuestionAnswer((bool)choosenAnswer.IsCorrect);
                NextQuestion();
            }
        }
        private void SaveQuestion(Item selectedItem)
        {
            try
            {
                selectedItem.ItemName = txtSurveyQuestion.Text;
                DataType selectedDataType = (DataType)cboDataType.SelectedItem;

                selectedItem.ValueType = selectedDataType.DisplayText;
                itemRepo.UpdateItem(selectedItem);

                btnEditQuestion.Content        = "Edit Question";
                btnAddSurveyQuestion.IsEnabled = true;
                btnDeleteQuestion.IsEnabled    = true;
                ClearFields();
            }
            catch
            {
                Jeeves.ShowMessage("Error", "Unable to save the question");
            }
            FillFields();
        }
Пример #24
0
        private void FillDropDown(int check)
        {
            DateTime now = DateTime.Today.AddDays(1);

            try
            {
                bool deleted = false;
                List <Models.Event> noDeletedEvents = eventRepository.GetEvents(deleted);
                //List<Event> upcomingEvents = noDeletedEvents
                //    .Where(c => c.EventEnd >= now)
                //    .OrderBy(c => c.EventStart)
                //    .ToList();
                //List<Event> pastEvents = noDeletedEvents
                //    .Where(c => c.EventEnd < now)
                //    .OrderByDescending(c => c.EventStart)
                //    .ToList();
                if (check == 1)
                {
                    List <Models.Event> upcomingEvents = noDeletedEvents
                                                         .Where(c => c.EventEnd >= now)
                                                         .OrderBy(c => c.EventStart)
                                                         .ToList();
                    gdvEvents.ItemsSource = upcomingEvents;
                }
                else
                {
                    List <Models.Event> pastEvents = noDeletedEvents
                                                     .Where(c => c.EventEnd < now)
                                                     .OrderByDescending(c => c.EventStart)
                                                     .ToList();
                    gdvEvents.ItemsSource = pastEvents;
                }
                //UpcomingEventList.ItemsSource = pastEvents;
                //UpcomingEventList.ItemsSource = noDeletedEvents;
            }
            catch (Exception e)
            {
                Jeeves.ShowMessage("Error", e.Message.ToString());
            }
        }
        private void FillFields(int itemDisplayOption)
        {
            try
            {
                List <Item> items = new List <Item>();

                if (itemDisplayOption == 1)
                {
                    items = itemRespository.GetUndeletedItemsByCount();
                }
                else if (itemDisplayOption == 0)
                {
                    items = itemRespository.GetUndeletedItems();
                }
                gvAvailableQuestions.ItemsSource           = items;
                gvAvailableQuestionsDeleteMode.ItemsSource = items;
            }
            catch (Exception)
            {
                Jeeves.ShowMessage("Error", "There was an error in retreving the questions");
            }
        }
Пример #26
0
        internal async Task WriteToAuditLog(string auditLine)
        {
            string fileName = "CAAAuditLog" + DateTime.Now.Month + DateTime.Now.Year + ".txt";

            //Heavily used: https://docs.microsoft.com/en-us/windows/uwp/files/quickstart-reading-and-writing-files

            try
            {
                Windows.Storage.StorageFolder storageFolder =
                    Windows.Storage.ApplicationData.Current.LocalFolder;

                Windows.Storage.StorageFile sampleFile =
                    await storageFolder.CreateFileAsync(fileName, Windows.Storage.CreationCollisionOption.OpenIfExists);

                auditLine = System.Environment.NewLine + auditLine;
                await Windows.Storage.FileIO.AppendTextAsync(sampleFile, auditLine);
            }
            catch (Exception)
            {
                Jeeves.ShowMessage("Error", "Failure to update audit log; please contact adminstrator");
            }
        }
        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 async void btnEditMultipurpose_Click(object sender, RoutedEventArgs e)
        {
            addOrEdit = 2;

            string selected = Convert.ToString(((Button)sender).DataContext);

            selectedItem = itemRespository.GetItem(selected.ToString());
            string warning = "Please exercise caution when editing this question. Do you wish to continue?";

            if (selectedItem != null)
            {
                var result = await Jeeves.ConfirmDialog("Warning", warning);

                if (result == ContentDialogResult.Secondary) //&& btnEditSurvey.Content.ToString() == "#xE74D;"
                {
                    ScreenLockDown();
                    BeginUpdate(selectedItem);
                }
                else if (result == ContentDialogResult.Secondary)
                {
                    SaveQuestion(selectedItem);
                }
            }
        }
Пример #29
0
 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.");
     }
 }
        private void SaveSurveyResponses()
        {
            foreach (var x in ListOfEID)
            {
                var surveyEntry = new AttendanceItem();
                surveyEntry.EventItemID        = x.EIDEventItemID;
                surveyEntry.MemberAttendanceID = tracker.MemberAttendanceID;

                if (tbkQuestionOne.Text == x.EIDItemPhrase)
                {
                    if (ckbAnswerOne.Visibility == Visibility.Visible && ckbAnswerOne.IsChecked == true)
                    {
                        surveyEntry.Answer = "true";
                    }
                    else if (ckbAnswerOne.Visibility == Visibility.Visible && ckbAnswerOne.IsChecked == false)
                    {
                        surveyEntry.Answer = "false";
                    }
                    else
                    {
                        surveyEntry.Answer = txtAnswerOne.Text;
                    }
                }
                else if (tbkQuestionTwo.Text == x.EIDItemPhrase)
                {
                    if (ckbAnswerTwo.Visibility == Visibility.Visible && ckbAnswerTwo.IsChecked == true)
                    {
                        surveyEntry.Answer = "true";
                    }
                    else if (ckbAnswerTwo.Visibility == Visibility.Visible && ckbAnswerTwo.IsChecked == false)
                    {
                        surveyEntry.Answer = "false";
                    }
                    else
                    {
                        surveyEntry.Answer = txtAnswerTwo.Text;
                    }
                }
                else if (tbkQuestionThree.Text == x.EIDItemPhrase)
                {
                    if (ckbAnswerThree.Visibility == Visibility.Visible && ckbAnswerThree.IsChecked == true)
                    {
                        surveyEntry.Answer = "true";
                    }
                    else if (ckbAnswerThree.Visibility == Visibility.Visible && ckbAnswerThree.IsChecked == false)
                    {
                        surveyEntry.Answer = "false";
                    }
                    else
                    {
                        surveyEntry.Answer = txtAnswerThree.Text;
                    }
                }
                else if (tbkQuestionFour.Text == x.EIDItemPhrase)
                {
                    if (ckbAnswerFour.Visibility == Visibility.Visible && ckbAnswerFour.IsChecked == true)
                    {
                        surveyEntry.Answer = "true";
                    }
                    else if (ckbAnswerFour.Visibility == Visibility.Visible && ckbAnswerFour.IsChecked == false)
                    {
                        surveyEntry.Answer = "false";
                    }
                    else
                    {
                        surveyEntry.Answer = txtAnswerFour.Text;
                    }
                }
                else if (tbkQuestionFive.Text == x.EIDItemPhrase)
                {
                    if (ckbAnswerFive.Visibility == Visibility.Visible && ckbAnswerFive.IsChecked == true)
                    {
                        surveyEntry.Answer = "true";
                    }
                    else if (ckbAnswerFive.Visibility == Visibility.Visible && ckbAnswerFive.IsChecked == false)
                    {
                        surveyEntry.Answer = "false";
                    }
                    else
                    {
                        surveyEntry.Answer = txtAnswerFive.Text;
                    }
                }

                try
                {
                    attendanceItemRepository.AddAttendanceItem(surveyEntry);
                }
                catch
                {
                    Jeeves.ShowMessage("Error", "There was a problem entering question " + x.EIDquestionCount.ToString());
                }
            }
        }