public int CreateTest(TestSettingsFormVM model, string username) { var authorId = GetUserIdByUsername(username); var test = new Test() { AuthorId = authorId, Name = model.TestName, Description = model.Description, Tags = null, ShowPassOrFail = model.ShowPassOrFail, ShowTestScore = model.ShowTestScore, CustomCompletionMessage = model.CustomCompletionMessage, TimeLimitInMinutes = model.TimeLimitInMinutes, PassPercentage = model.PassPercentage, NumberOfFeaturedQuestions = model.NumberOfFeaturedQuestions, CertificateAuthor = model.CertificateAuthor, CertificateCompany = model.CertificateCompany, CertificateCustomText = model.CertificateCustomText, CertificateTemplatePath = model.CertificateTemplatePath, EnableCertificateDownloadOnCompletion = model.EnableCertificateDownloadOnCompletion, EnableEmailCertificateOnCompletion = model.EnableEmailCertificateOnCompletion }; context.Tests.Add(test); context.SaveChanges(); return(test.Id); }
public IActionResult CreateTest(TestSettingsFormVM model) { if (!ModelState.IsValid) { return(View(model)); } var testId = repository.CreateTest(model, User.Identity.Name); return(RedirectToAction(nameof(AdminController.ManageTestQuestions), new { testId = testId })); }
public void EditTestSettings(TestSettingsFormVM viewModel, int testId) { var thisTest = context.Tests.SingleOrDefault(o => o.Id == testId); thisTest.Description = viewModel.Description; thisTest.Name = viewModel.TestName; thisTest.Tags = viewModel.Tags; thisTest.ShowPassOrFail = viewModel.ShowPassOrFail; thisTest.ShowTestScore = viewModel.ShowTestScore; thisTest.CustomCompletionMessage = viewModel.CustomCompletionMessage; thisTest.TimeLimitInMinutes = viewModel.TimeLimitInMinutes; thisTest.PassPercentage = viewModel.PassPercentage; thisTest.NumberOfFeaturedQuestions = viewModel.NumberOfFeaturedQuestions; thisTest.CertificateAuthor = viewModel.CertificateAuthor; thisTest.CertificateCompany = viewModel.CertificateCompany; thisTest.CertificateCustomText = viewModel.CertificateCustomText; thisTest.CertificateTemplatePath = viewModel.CertificateTemplatePath; thisTest.EnableCertificateDownloadOnCompletion = viewModel.EnableCertificateDownloadOnCompletion; thisTest.EnableEmailCertificateOnCompletion = viewModel.EnableEmailCertificateOnCompletion; }
public IActionResult EditTestSettings(TestSettingsFormVM viewModel, int testId) { repository.EditTestSettings(viewModel, testId); return(RedirectToAction(nameof(AdminController.ManageTestQuestions), new { testId = testId })); }