// GET: service_desk/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } service_desk service_desk = db.service_desk.Find(id); if (service_desk == null) { return(HttpNotFound()); } ViewBag.kind_id = new SelectList(db.sd_kind, "id", "name", service_desk.kind_id); ViewBag.status_id = new SelectList(db.sd_status, "id", "name", service_desk.status_id); ViewBag.user_id = new SelectList(db.users, "username", "fio", service_desk.user_id); // для передачи в представление используем ViewBag // Если заявка закрыта, то статус не показываем if (service_desk.status_id == 1) { ViewBag.showStatus = true; } else { ViewBag.showStatus = false; } return(View(service_desk)); }
public ActionResult DeleteConfirmed(int id) { service_desk service_desk = db.service_desk.Find(id); db.service_desk.Remove(service_desk); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: service_desk/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } service_desk service_desk = db.service_desk.Find(id); if (service_desk == null) { return(HttpNotFound()); } return(View(service_desk)); }
public ActionResult Create([Bind(Include = "number_request,author,kind_id,date_begin,date_end,status_id,comment,task,what_done,user_id,fio")] service_desk service_desk) { if (ModelState.IsValid) { service_desk.author = User.Identity.GetUserName(); service_desk.date_begin = DateTime.Now; service_desk.status_id = 1; db.service_desk.Add(service_desk); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.kind_id = new SelectList(db.sd_kind, "id", "name", service_desk.kind_id); ViewBag.status_id = new SelectList(db.sd_status, "id", "name", service_desk.status_id); ViewBag.user_id = new SelectList(db.users, "username", "fio", service_desk.user_id); return(View(service_desk)); }
public ActionResult Edit([Bind(Include = "number_request,author,kind_id,date_begin,date_end,status_id,comment,task,what_done,user_id,fio")] service_desk service_desk) { if (ModelState.IsValid) { if (service_desk.status_id == 2 && service_desk.date_end == null) { service_desk.date_end = DateTime.Now; } db.Entry(service_desk).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.kind_id = new SelectList(db.sd_kind, "id", "name", service_desk.kind_id); ViewBag.status_id = new SelectList(db.sd_status, "id", "name", service_desk.status_id); ViewBag.user_id = new SelectList(db.users, "username", "fio", service_desk.user_id); return(View(service_desk)); }