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(); } }
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(); } } }
private async void HandleSignIn() { //var login = await http //.PostJsonAsync<LoginView>("/api/accounts/authenticate", new Coronassist.Web.Shared.Models.UserDto //{ // Email = Email, // Password = Password //}); var login = await ApplicationUserRepository.AuthenticateAsync(new Coronassist.Web.Shared.Models.UserDto { Email = Email, Password = Password }); if (login.IsSuccess) { State.User = login.ApplicationUser; StateHasChanged(); NavigationManager.NavigateTo("dashboard"); } else { await SweetAlertMessage.ErrorMessage(Text : "Can't log you in, invalid username or password"); } // System.Console.WriteLine("HandleSignInDone"); }
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(); } } } }
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"); } } }
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"); } }
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(); } }
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(); } }); }
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(); } } }
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; } } }
protected async override Task OnInitializedAsync() { SweetAlertMessage.Prepare(JSRuntime); Users = await ApplicationUserRepository.GetAll(); }
protected async override Task OnInitializedAsync() { SweetAlertMessage.Prepare(JSRuntime); }
protected override void OnInitialized() { SweetAlertMessage.Prepare(JSRuntime); }
protected async override Task OnInitializedAsync() { SweetAlertMessage.Prepare(JSRuntime); Answers = new HashSet <Answer>(); Survey = await SurveyRepository.GetSurvey(SurveyId); }