public ActionResult Edit(int id, TestViewModel test) { if (test != null && this.ModelState.IsValid) { var existingTest = this.Data.Tests .All() .FirstOrDefault(t => t.Id == id); if (existingTest == null) { this.TempData.AddDangerMessage(Resource.Invalid_test); return this.RedirectToAction("Problem", new { id }); } existingTest.InputData = test.InputData; existingTest.OutputData = test.OutputData; existingTest.OrderBy = test.OrderBy; existingTest.IsTrialTest = test.IsTrialTest; this.Data.SaveChanges(); this.RetestSubmissions(existingTest.ProblemId); this.TempData.AddInfoMessage(Resource.Test_edited_successfully); return this.RedirectToAction("Problem", new { id = existingTest.ProblemId }); } return this.View(test); }
public ActionResult Create(int? id) { if (id == null) { this.TempData.AddDangerMessage(Resource.Invalid_problem); return this.RedirectToAction(GlobalConstants.Index); } var problem = this.Data.Problems.All().FirstOrDefault(pr => pr.Id == id); if (problem == null) { this.TempData.AddDangerMessage(Resource.Invalid_problem); return this.RedirectToAction(GlobalConstants.Index); } var test = new TestViewModel { ProblemId = problem.Id, ProblemName = problem.Name, }; return this.View(test); }
public ActionResult Create(int id, TestViewModel test) { var problem = this.Data.Problems.All().FirstOrDefault(pr => pr.Id == id); if (problem == null) { this.TempData.AddDangerMessage(Resource.Invalid_problem); return this.RedirectToAction(GlobalConstants.Index); } if (test != null && this.ModelState.IsValid) { this.Data.Tests.Add(new Test { InputDataAsString = test.InputFull, OutputDataAsString = test.OutputFull, ProblemId = id, IsTrialTest = test.IsTrialTest, OrderBy = test.OrderBy }); this.Data.SaveChanges(); this.RetestSubmissions(problem.Id); this.TempData.AddInfoMessage(Resource.Test_added_successfully); return this.RedirectToAction("Problem", new { id }); } return this.View(test); }
public ActionResult Edit(int id, TestViewModel test) { if (test != null && this.ModelState.IsValid) { var existingTest = this.Data.Tests .All() .FirstOrDefault(t => t.Id == id); if (existingTest == null) { this.TempData[GlobalConstants.DangerMessage] = "Невалиден тест"; return this.RedirectToAction("Problem", new { id }); } existingTest.InputData = test.InputData; existingTest.OutputData = test.OutputData; existingTest.OrderBy = test.OrderBy; existingTest.IsTrialTest = test.IsTrialTest; this.Data.SaveChanges(); this.RetestSubmissions(existingTest.Problem); this.TempData[GlobalConstants.InfoMessage] = "Тестът беше променен успешно."; return this.RedirectToAction("Problem", new { id = existingTest.ProblemId }); } return this.View(test); }
public ActionResult Create(int id, TestViewModel test) { var problem = this.Data.Problems.All().FirstOrDefault(pr => pr.Id == id); if (problem == null) { this.TempData[GlobalConstants.DangerMessage] = "Невалидна задача"; return this.RedirectToAction(GlobalConstants.Index); } if (test != null && this.ModelState.IsValid) { this.Data.Tests.Add(new Test { InputDataAsString = test.InputFull, OutputDataAsString = test.OutputFull, ProblemId = id, IsTrialTest = test.IsTrialTest, OrderBy = test.OrderBy }); this.Data.SaveChanges(); this.RetestSubmissions(problem); this.TempData[GlobalConstants.InfoMessage] = "Тестът беше добавен успешно."; return this.RedirectToAction("Problem", new { id }); } return this.View(test); }
public ActionResult Edit(int id, TestViewModel test) { var hasProblem = this.Data.Tests.All().Any(t => t.Id == id); if (!hasProblem) { this.TempData["DangerMessage"] = "Невалиден тест"; return this.RedirectToAction("Index"); } if (test != null && ModelState.IsValid) { var existingTest = this.Data.Tests.All() .FirstOrDefault(t => t.Id == id); existingTest.InputData = test.InputData; existingTest.OutputData = test.OutputData; existingTest.OrderBy = test.OrderBy; existingTest.IsTrialTest = test.IsTrialTest; this.Data.SaveChanges(); this.TempData["InfoMessage"] = "Теста беше променен успешно"; return this.RedirectToAction("Problem", new { id = existingTest.ProblemId }); } return this.View(test); }
public ActionResult Create(int id, TestViewModel test) { var hasProblem = this.Data.Problems.All().Any(pr => pr.Id == id); if (!hasProblem) { this.TempData["DangerMessage"] = "Невалидна задача"; return this.RedirectToAction("Index"); } if (test != null && this.ModelState.IsValid) { this.Data.Tests.Add(new Test { InputDataAsString = test.InputFull, OutputDataAsString = test.OutputFull, ProblemId = id, IsTrialTest = test.IsTrialTest, OrderBy = test.OrderBy }); this.Data.SaveChanges(); this.TempData["InfoMessage"] = "Теста беше добавен успешно"; return this.RedirectToAction("Problem", new { id = id }); } return this.View(test); }
public ActionResult Create(int? id) { if (id == null) { this.TempData["DangerMessage"] = "Невалидна задача"; return this.RedirectToAction("Index"); } var problem = this.Data.Problems.All().FirstOrDefault(pr => pr.Id == id); if (problem == null) { this.TempData["DangerMessage"] = "Невалидна задача"; return this.RedirectToAction("Index"); } var test = new TestViewModel { ProblemId = problem.Id, ProblemName = problem.Name, }; return this.View(test); }