// GET: Feedback/Create public ActionResult Create(int?id) { UserTask userTask = userTaskService.GetAll().Where(x => x.ID == id).FirstOrDefault(); Task task = taskService.Get(userTask.TaskID); User user = userService.Get(userTask.UserID); ExtentionTaskViewModel model = new ExtentionTaskViewModel { ID = userTask.ID, Answer = userTask.Answer, Comment = userTask.Comment, Grade = userTask.Grade, Section = task.Section, Task = task, User = user, SectionID = task.Section.ID, TaskID = task.ID, UserID = user.ID }; ViewBag.Grade = new SelectList(new List <string>() { "Отлично", "Хорошо", "Удовлетворительно", "Неудовлетворительно" }, "ID"); return(View(model)); }
// GET: Feedback/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserTask userTask = userTaskService.GetAll().Where(x => x.ID == id).FirstOrDefault(); if (userTask == null) { return(HttpNotFound()); } var task = taskService.Get(userTask.TaskID); ExtentionTaskViewModel model = new ExtentionTaskViewModel { ID = userTask.ID, Answer = userTask.Answer, Comment = userTask.Comment, Grade = userTask.Grade, Task = task, Section = task.Section, User = userService.Get(userTask.UserID) }; return(View(model)); }
// GET: Feedback/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserTask userTask = userTaskService.GetAll().Where(x => x.ID == id).FirstOrDefault(); if (userTask == null) { return(HttpNotFound()); } var task = taskService.Get(userTask.TaskID); ExtentionTaskViewModel model = new ExtentionTaskViewModel { ID = userTask.ID, Answer = userTask.Answer, Comment = userTask.Comment, Grade = userTask.Grade, Task = task, Section = task.Section, User = userService.Get(userTask.UserID), SectionID = task.Section.ID, TaskID = task.ID, UserID = userTask.UserID }; ViewBag.SectionID = new SelectList(sectionService.GetAll(), "ID", "Description", model.Section.ID); if (model.Grade != null) { ViewBag.Grade = new SelectList(new List <string>() { "Отлично", "Хорошо", "Удовлетворительно", "Неудовлетворительно" }, model.Grade); } else { ViewBag.Grade = new SelectList(new List <string>() { "Отлично", "Хорошо", "Удовлетворительно", "Неудовлетворительно" }, "ID"); } return(View(model)); }
public ActionResult Edit(ExtentionTaskViewModel model) { if (ModelState.IsValid) { UserTask userTask = new UserTask { ID = model.ID, TaskID = (int)model.TaskID, UserID = (int)model.UserID, Answer = model.Answer, Comment = model.Comment, Grade = model.Grade }; userTaskService.Edit(userTask); return(RedirectToAction("Index", "Profile")); } ViewBag.SectionID = new SelectList(sectionService.GetAll(), "ID", "Description", model.Section.ID); if (model.Grade != null) { ViewBag.Grade = new SelectList(new List <string>() { "Отлично", "Хорошо", "Удовлетворительно", "Неудовлетворительно" }, "ID", "Description", model.Grade); } else { ViewBag.Grade = new SelectList(new List <string>() { "Отлично", "Хорошо", "Удовлетворительно", "Неудовлетворительно" }, "ID"); } return(View(model)); }
public ActionResult Create(ExtentionTaskViewModel task) { if (ModelState.IsValid) { userTaskService.Delete(userTaskService.GetAll().Where(x => x.ID == task.ID).FirstOrDefault()); userTaskService.Create(new UserTask { Answer = task.Answer, Comment = task.Comment, Grade = task.Grade, TaskID = (int)task.TaskID, UserID = (int)task.UserID }); return(RedirectToAction("Index", "Profile")); } ViewBag.Grade = new SelectList(new List <string>() { "Отлично", "Хорошо", "Удовлетворительно", "Неудовлетворительно" }, "ID", task.Grade); return(View(task)); }