예제 #1
0
        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 });
        }
예제 #2
0
        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);
        }
예제 #3
0
        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 });
        }