public ActionResult EditTask(ManageTaskViewModel model) { var dbModel = new Tasks { Title = model.Title, Description = model.Description, StartDate = model.StartDate.Add(model.StartTime), EndDate = model.EndDate.Add(model.EndTime), Example = model.Example, Input = model.Input, Id = model.TaskId, InputDataTypeId = model.InputDataId, Output = model.Output, MaxExecuteMemory = model.MaxExecutedMemory, MaxExecuteTime = model.MaxExecutedTime }; if (model.PDF != null) { byte[] newPDF = new byte[model.PDF.ContentLength]; model.PDF.InputStream.Read(newPDF, 0, model.PDF.ContentLength); dbModel.PDF = newPDF; } bool result = _tournamentManager.EditTask(dbModel); if (result) TempData["Alert"] = SetAlert.Set("Poprawnie edytowano: " + dbModel.Title, "Sukces", AlertType.Success); else TempData["Alert"] = SetAlert.Set("Wystąpił błąd. Spróbuj ponownie później!", "Błąd", AlertType.Danger); return RedirectToAction("Index"); }
public ActionResult EditTask(int taskId) { var dbModel = _tournamentManager.Tasks .Where(x => x.Id == taskId) .FirstOrDefault(); var viewModel = new ManageTaskViewModel { Title = dbModel.Title, Output = dbModel.Output, Input = dbModel.Input, InputDataId = dbModel.InputDataTypeId, Example = dbModel.Example, EndDate = dbModel.EndDate, EndTime = dbModel.EndDate.TimeOfDay, StartDate = dbModel.StartDate, StartTime = dbModel.StartDate.TimeOfDay, Description = dbModel.Description, MaxExecutedMemory = dbModel.MaxExecuteMemory, MaxExecutedTime = dbModel.MaxExecuteTime, TaskId = dbModel.Id, InputData = GetDataInputList(dbModel.InputDataTypeId) }; return View(viewModel); }