public ActionResult ReopenTicket(Ticket ticket) { Ticket dbTicket = db.Tickets.Find(ticket.ticketID); ticket.UpdatedDate = DateTime.Now; if (dbTicket.AssigneeID != null) { dbTicket.Status = db.Status.Single(x => x.statusName == "In Progress"); } else { dbTicket.Status = db.Status.Single(x => x.statusName == "Opened"); } db.SaveChanges(); return RedirectToAction("Details", new { id = ticket.ticketID }); }
public ActionResult Create(Ticket ticket) { if (ModelState.IsValid) { int userID = CurrentUser.GetUserID().Value; ticket.userID = userID; ticket.CreatedDate = DateTime.Now; ticket.UpdatedDate = DateTime.Now; ticket.Status = db.Status.Single(x => x.statusName == "Opened"); #region File Upload List<File> fileList = new List<Models.File>(); for (int i = 0; i < Request.Files.Count; ++i) { File fileUpload = FileHelper.Save(Request.Files[i], Server.MapPath("~/App_Data/uploads")); fileList.Add(fileUpload); } var dbFiles = from dbFile in db.Files.ToList() join file in fileList on dbFile.fileID equals file.fileID select dbFile; ticket.Files = dbFiles.ToList(); #endregion db.Tickets.Add(ticket); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.catagoryID = new SelectList(db.Catagories, "catagoryID", "catagoryName", ticket.catagoryID); ViewBag.statusID = new SelectList(db.Status, "statusID", "statusName", ticket.statusID); ViewBag.userID = new SelectList(db.Users, "userID", "userFname", ticket.userID); return View(ticket); }
public ActionResult CloseTicket(Ticket ticket) { Ticket dbTicket = db.Tickets.Find(ticket.ticketID); ticket.UpdatedDate = DateTime.Now; if (CurrentUser.GetUserID().Value == dbTicket.userID) { dbTicket.Status = db.Status.Single(x=> x.statusName == "Closed"); } else if (CurrentUser.GetRoles().Any(x => x.Name == "Admin" || x.Name == "IT User")) { dbTicket.Status = db.Status.Single(x => x.statusName == "Waiting for closing"); } db.SaveChanges(); return RedirectToAction("Details", new { id = ticket.ticketID }); }