Esempio n. 1
0
        private async void AddSurveyAsync()
        {
            if (!string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Description) && !string.IsNullOrEmpty(LowUpperBound) && !string.IsNullOrEmpty(MidUpperBound))
            {
                var survey = await SurveyRepository.AddSurvey(new Survey
                {
                    Name          = Name,
                    Description   = Description,
                    CreatedOn     = DateTime.Now,
                    SurveyStatus  = SurveyStatus.Pending,
                    LowUpperBound = double.Parse(LowUpperBound),
                    MidUpperBound = double.Parse(MidUpperBound)
                });

                if (survey != null)
                {
                    Name          = string.Empty;
                    Description   = string.Empty;
                    LowUpperBound = string.Empty;
                    MidUpperBound = string.Empty;
                    await SweetAlertMessage.SuccessMessage();
                }
                else
                {
                    await SweetAlertMessage.ErrorMessage();
                }
            }
            else
            {
                await SweetAlertMessage.ErrorMessage();
            }
        }
Esempio n. 2
0
        private async void AddUserAsync()
        {
            if (!string.IsNullOrEmpty(LastName) && !string.IsNullOrEmpty(FirstName) && !string.IsNullOrEmpty(Province) && !string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(PhoneNumber))
            {
                var user = await ApplicationUserRepository.CreateAsync(
                    new Usermodel
                {
                    Fullname        = $"{FirstName} {LastName}",
                    Email           = Email,
                    PhoneNumber     = PhoneNumber,
                    ConfirmPassword = "******",
                    Password        = "******",
                    Province        = Province,
                    FullAddress     = FullAddress,
                    Role            = "Doctor"
                });

                if (user.identityResult.Succeeded)
                {
                    FirstName   = string.Empty;
                    Email       = string.Empty;
                    PhoneNumber = string.Empty;
                    FullAddress = string.Empty;
                    LastName    = string.Empty;
                    Province    = string.Empty;
                    StateHasChanged();
                    await SweetAlertMessage.SuccessMessage();
                }
            }
        }
Esempio n. 3
0
        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();
                    }
                }
            }
        }
Esempio n. 4
0
        private async void SubmitSurvey()
        {
            var answers = new List <SurveyAnswer>();

            if (UserAnswers.Count > 0 && !string.IsNullOrEmpty(UserId))
            {
                //Submit UserSurvey
                var userSurvey = await AccountSurveyRepository.AddAccountSurvey(new AccountSurvey
                {
                    Id               = UserId,
                    SurveyId         = Survey.SurveyId,
                    Risk             = UserAnswers.Sum(p => p.Percentage),
                    SurveyDate       = DateTime.Now,
                    UserSurveyStatus = SurveyResult(UserAnswers.Sum(p => p.Percentage))
                });

                if (userSurvey != null)
                {
                    foreach (var userAnswer in UserAnswers)
                    {
                        answers.Add(new SurveyAnswer
                        {
                            AccountSurveyId = userSurvey.AccountSurveyId,
                            Answer          = userAnswer.UserAnswer,
                            Question        = userAnswer.Question.SurveyQuestion
                        });
                    }
                    var added = await QuestionAnswerRepository.AddRange(answers);

                    if (added)
                    {
                        Open = false;
                        StateHasChanged();
                        await SweetAlertMessage.SuccessMessage();

                        //Navigate to show results
                    }
                    else
                    {
                        await SweetAlertMessage.ErrorMessage();
                    }
                }
            }
            else
            {
                await SweetAlertMessage.ErrorMessage(Text : "Survey not completed, please answer atleast one question");
            }
        }
Esempio n. 5
0
        private async void SubmitQuestion()
        {
            Task task = Task.Run(async() =>
            {
                var _question = await SweetAlertMessage.InputDialog(type: "textarea", PlaceholderText: "Type your survey question here....");
                if (!string.IsNullOrEmpty(_question))
                {
                    var question = await QuestionRepository.AddQuestionAsync(new Coronassist.Web.Shared.Models.Question
                    {
                        SurveyQuestion = _question,
                        IsActive       = true,
                        SurveyId       = SurveyId
                    });

                    this.Survey.Questions.Add(question);
                    await SweetAlertMessage.SuccessMessage();
                    Open = false;
                    StateHasChanged();
                }
            });
        }
Esempio n. 6
0
        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();
                }
            }
        }