Beispiel #1
0
        public async Task <ActionResult> TitleEdit(string Title, string Description, int ticketId)
        {
            var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticketId);
            var ticket    = db.Tickets.Find(ticketId);

            if (ticket == null || Title == null || Description == null)
            {
                return(View(ticket));
            }

            ticket.Title       = Title;
            ticket.Description = Description;

            db.Tickets.Attach(ticket);
            db.Entry(ticket).Property(t => t.Title).IsModified       = true;
            db.Entry(ticket).Property(t => t.Description).IsModified = true;
            if (!User.IsInRole("Demo"))
            {
                db.SaveChanges();
                await notifyHelper.Notify(oldTicket, ticket);

                historyHelper.AddHistories(oldTicket, ticket);
            }
            ;

            TempData["TicketMessage"] = "Ticket Updated Successfully.";
            return(RedirectToAction("Details", new { id = ticketId }));
        }
        public async Task <ActionResult> EditTicketDev(int ticketId, string Developers)
        {
            var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticketId);
            var ticket    = db.Tickets.Find(ticketId);

            if (Developers == "")
            {
                await ticketHelper.UnassignUserFromTicket(ticketId, ticket.AssignedUserId);

                TempData["TicketMessage"] = "Unassigned Ticket Successfully.";
                return(RedirectToAction("Details", "Tickets", new { id = ticketId }));
            }

            ticket.AssignedUserId = Developers;
            db.Entry(ticket).Property(t => t.AssignedUserId).IsModified = true;

            if (!User.IsInRole("Demo"))
            {
                db.SaveChanges();
                await notifyHelper.Notify(oldTicket, ticket);

                historyHelper.AddHistories(oldTicket, ticket);
            }
            TempData["TicketMessage"] = "Assigned Dev Changed Successfully.";
            return(RedirectToAction("Details", "Tickets", new { id = ticketId }));
        }