private async void AddAnswer(int QuestionId)
        {
            var answer = await SweetAlertMessage.InputDialog(type : "textarea", PlaceholderText : "Type your survey answer here....");

            if (!string.IsNullOrEmpty(answer))
            {
                var percentage = await SweetAlertMessage.RiskWeight();

                var confirm = await SweetAlertMessage.ConfirmDialogAsync(Text : "Add this answe to the question.");

                if (confirm != null)
                {
                    var _answer = await AnswerRepository.AddAnswer(new Answer
                    {
                        QuestionId = QuestionId,
                        IsActive   = true,
                        Percentage = double.Parse(percentage),
                        UserAnswer = answer,
                        AnswerType = AnswerType.No
                    });

                    if (_answer != null)
                    {
                        var _updatedQuestion = Survey.Questions.FirstOrDefault(p => p.QuestionId == QuestionId);
                        _updatedQuestion.Answers.Add(_answer);
                        StateHasChanged();
                        await SweetAlertMessage.SuccessMessage();
                    }
                    else
                    {
                        await SweetAlertMessage.ErrorMessage();
                    }
                }
            }
        }
Example #2
0
        private async void TakeSurvey(string Id)
        {
            Surveys = new HashSet <Survey>();
            var confirm = await SweetAlertMessage.ConfirmDialogAsync(Title : "Take Survey", Text : "Choose any available survey.");

            if (confirm == "Yes")
            {
                Surveys = await SurveyRepository.GetSurveys();

                Open = true;
            }
        }
        private async void DeleteSurvey()
        {
            var confirm = await SweetAlertMessage.ConfirmDialogAsync(Text : "Delete this survey");

            if (confirm == "Yes")
            {
                var deleted = await SurveyRepository.DeleteSurvey(Survey.SurveyId);

                if (deleted)
                {
                    NavigationManager.NavigateTo("surveys");
                }
            }
        }
Example #4
0
        private async void TakeSurvey(string Id)
        {
            UserId  = Id;
            Surveys = new HashSet <Survey>();
            var confirm = await SweetAlertMessage.ConfirmDialogAsync(Title : "Take Survey", Text : "Choose any available survey.");

            if (confirm == "Yes")
            {
                Surveys = await SurveyRepository.GetSurveys();

                Survey = await SurveyRepository.GetSurvey(Surveys.FirstOrDefault().SurveyId);

                Open = true;
                StateHasChanged();
            }
        }
Example #5
0
        private async void DeleteUser(ApplicationUser applicationUser)
        {
            try
            {
                var confirm = await SweetAlertMessage.ConfirmDialogAsync(Text : $"Delete {applicationUser.Fullname}", ConfirmButtonText : "Delete");

                if (confirm == "Yes")
                {
                    var deleted = await ApplicationUserRepository.DeleteUser(applicationUser.Id);

                    if (deleted)
                    {
                        Users.Remove(applicationUser);
                        StateHasChanged();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        private async void DeleteQuestion(int QuestionId)
        {
            var confirm = await SweetAlertMessage.ConfirmDialogAsync(Text : "Delete selected question");

            if (confirm == "Yes")
            {
                var deleted = await QuestionRepository.DeleteQuestion(QuestionId);

                if (deleted)
                {
                    var deleteItem = Survey.Questions.FirstOrDefault(p => p.QuestionId == QuestionId);
                    Survey.Questions.Remove(deleteItem);
                    await SweetAlertMessage.SuccessMessage();

                    StateHasChanged();
                }
                else
                {
                    await SweetAlertMessage.ErrorMessage();
                }
            }
        }
Example #7
0
        private async void DeclineBooking(Book book)
        {
            var confirm = await SweetAlertMessage.ConfirmDialogAsync("Update selected Booking");

            if (confirm == "Yes")
            {
                switch (book.BookingStatus)
                {
                case BookingStatus.Booked:
                {
                    book.BookingStatus = BookingStatus.Declined;
                    await UpdateBook(book);
                }
                break;

                case BookingStatus.Declined:
                {
                    book.BookingStatus = BookingStatus.Booked;
                    await UpdateBook(book);
                }
                break;
                }
            }
        }