public ActionResult DeleteConfirmed(int id)
        {
            tickethistory tickethistory = db.tickethistory.Find(id);

            db.tickethistory.Remove(tickethistory);
            db.SaveChanges();
            return(RedirectToAction("Index", "tickethistory", new { TicketOwner = tickethistory.TicketId }));
        }
 public ActionResult Edit([Bind(Include = "TicketHistoryId,TicketId,TicketHistoryUserId,TicketHistoryDetail,TicketHistoryDate")] tickethistory tickethistory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tickethistory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "tickethistory", new { TicketOwner = tickethistory.TicketId }));
     }
     ViewBag.TicketId            = new SelectList(db.ticket, "TicketId", "TicketIssueSubject", tickethistory.TicketId);
     ViewBag.TicketHistoryUserId = new SelectList(db.user, "UserId", "UserName", tickethistory.TicketHistoryUserId);
     return(View(tickethistory));
 }
        // GET: tickethistory/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tickethistory tickethistory = db.tickethistory.Find(id);

            if (tickethistory == null)
            {
                return(HttpNotFound());
            }
            return(View(tickethistory));
        }
        // GET: tickethistory/Details/5
        public ActionResult Details(int?id, int?TicketOwner)
        {
            ViewBag.TicketOwner = ((TicketOwner == null) ? ViewBag.TicketId : TicketOwner);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tickethistory tickethistory = db.tickethistory.Find(id);

            if (tickethistory == null)
            {
                return(HttpNotFound());
            }
            return(View(tickethistory));
        }
        // GET: tickethistory/Edit/5
        public ActionResult Edit(int?id, int?TicketOwner)
        {
            ViewBag.TicketOwner = ((TicketOwner == null) ? ViewBag.TicketId : TicketOwner);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tickethistory tickethistory = db.tickethistory.Find(id);

            if (tickethistory == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TicketId            = new SelectList(db.ticket, "TicketId", "TicketIssueSubject", TicketOwner);
            ViewBag.TicketHistoryUserId = new SelectList(db.user, "UserId", "UserName", tickethistory.TicketHistoryUserId);

            return(View(tickethistory));
        }
        public ActionResult Create([Bind(Include = "TicketHistoryId,TicketId,TicketHistoryUserId,TicketHistoryDetail,TicketHistoryDate,StatusDetailId")] tickethistory tickethistory)
        {
            if (ModelState.IsValid)
            {
                if (tickethistory.ticket.StatusDetailId != 11)
                {
                    ticket tic = (from x in db.ticket
                                  where x.TicketId == tickethistory.TicketId
                                  select x).First();
                    tic.StatusId       = 3;
                    tic.StatusDetailId = tickethistory.ticket.StatusDetailId;
                    db.SaveChanges();
                }

                db.tickethistory.Add(tickethistory);

                db.SaveChanges();
                return(RedirectToAction("Index", "tickethistory", new { TicketOwner = tickethistory.TicketId }));
            }

            ViewBag.TicketId            = new SelectList(db.ticket, "TicketId", "TicketIssueSubject", tickethistory.TicketId);
            ViewBag.TicketHistoryUserId = new SelectList(db.user, "UserId", "UserName", tickethistory.TicketHistoryUserId);
            return(View(tickethistory));
        }