public IActionResult OnPost(int TestID) { apTestData.DeleteTest(TestID); apTestData.Commit(); TempData["Message"] = "Test has successfully been deleted"; return(RedirectToPage("./TestList")); }
public IActionResult OnPost(string UserID) { apTestData.DeleteAppUser(UserID); apTestData.Commit(); TempData["Message"] = "AppUser has been successfully deleted"; return(RedirectToPage("./BulkRegister")); }
public IActionResult OnPost(string[] checkboxes) { if (Test.ID > 0) { apTestData.UpdateTest(Test); apTestData.UpdateTestQuestions(Test, checkboxes); TempData["Message"] = "Test has been updated"; } else { var CreatedTest = apTestData.AddTest(Test); apTestData.Commit(); apTestData.AddQuestionsToTest(CreatedTest, checkboxes); TempData["Message"] = "Test has been created"; } apTestData.Commit(); return(RedirectToPage("./TestDetail", new { TestID = Test.ID })); }
public IActionResult OnPost(string UserID) { apTestData.UpdateAppUser(AppUser); apTestData.Commit(); if (IsAdmin) { TempData["Message"] = "Admin's details have been updated"; } else { TempData["Message"] = "Applicant's details have been updated"; } return(RedirectToPage("AppUserDetail/", UserID)); }
public IActionResult OnPost(string[] userCheckboxes) { var TestUsers = apTestData.GetApplicantsAssignedToTestByID(Test.ID); if (TestUsers.Count == 0) { apTestData.AddApplicantsToTest(Test, userCheckboxes); TempData["Message"] = "Users Added to Test"; } else { apTestData.UpdateApplicantsAssignedToTest(Test, userCheckboxes); TempData["Message"] = "Test Users Updated"; } apTestData.Commit(); return(RedirectToPage("./TestDetail", new { TestID = Test.ID })); }
public async Task <IActionResult> OnPost() { List <UserUploadCargo> records; List <AppUser> usersToAdd = new List <AppUser>(); var file = UserFile; if (file is null) { return(Page()); } string fileExt = Path.GetExtension(file.FileName); if (fileExt != ".csv") { AppUsers = apTestData.GetAllAppUsers(); TempData["ErrorMessage"] = "File is not in CSV format, please select a CSV file"; return(RedirectToPage("BulkRegister")); } else { var reader = new StreamReader(file.OpenReadStream()); var csv = new CsvReader(reader, CultureInfo.InvariantCulture); records = csv.GetRecords <UserUploadCargo>().ToList(); foreach (var record in records) { var appUser = new AppUser { Id = record.ID, UserName = record.Email, NormalizedUserName = record.Email.ToUpper(), Email = record.Email, NormalizedEmail = record.Email.ToUpper(), FirstName = record.FirstName, LastName = record.LastName, PhoneNumber = record.PhoneNumber, Address = record.Address, City = record.City, Country = record.Country, PostCode = record.PostCode, }; var passwordHasher = new PasswordHasher <AppUser>(); var hashedPassword = passwordHasher.HashPassword(appUser, record.Password); appUser.PasswordHash = hashedPassword; appUser.SecurityStamp = Guid.NewGuid().ToString(); usersToAdd.Add(appUser); } apTestData.AddNewApplicant(usersToAdd); apTestData.Commit(); foreach (var user in usersToAdd) { await _userManager.AddClaimAsync(user, new System.Security.Claims.Claim("FullName", user.FirstName + " " + user.LastName)); } TempData["Message"] = "All applicants have been successfully created"; } apTestData.Commit(); return(RedirectToPage("BulkRegister")); }