Esempio n. 1
0
        public ActionResult Advance(int ticketId)
        {
            var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticketId);
            var ticket    = db.Tickets.Find(ticketId);

            if (ticket.TicketStatus.Name == "Assigned")
            {
                ticket.TicketStatusId = db.TicketStatuses.FirstOrDefault(t => t.Name == "Assigned / In Progress").Id;
                ticket.Updated        = DateTime.Now;
                db.SaveChanges();

                HistoryHelper.RecordHistory(oldTicket, ticket);
                return(RedirectToAction("Details", "Tickets", new { id = ticketId }));
            }


            if (ticket.TicketStatus.Name == "Assigned / In Progress")
            {
                ticket.TicketStatusId = db.TicketStatuses.FirstOrDefault(t => t.Name == "Resolved").Id;

                ticket.Updated = DateTime.Now;
                db.SaveChanges();
                HistoryHelper.RecordHistory(oldTicket, ticket);
                return(RedirectToAction("Details", "Tickets", new { id = ticketId }));
            }


            return(RedirectToAction("Details", "Tickets", new { id = ticketId }));
        }
Esempio n. 2
0
        public async Task <ActionResult> AssignTicket(Ticket model)
        {
            var ticket = db.Tickets.Find(model.Id);

            ticket.AssignedToUserId = model.AssignedToUserId;
            var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id);

            db.SaveChanges();

            NotificationHelper.CreateAssignmentNotification(oldTicket, ticket);
            var historyHelper = new HistoryHelper();

            historyHelper.RecordHistory(oldTicket, ticket);
            var callbackUrl = Url.Action("Details", "Tickets", new { id = ticket.Id },
                                         protocol: Request.Url.Scheme);

            try
            {
                EmailService    ems  = new EmailService();
                IdentityMessage msg  = new IdentityMessage();
                ApplicationUser user = db.Users.Find(model.AssignedToUserId);
                msg.Body = "You have been assigned to a new Ticket." + Environment.NewLine +
                           "please click the following link to view details" +
                           "<a href=\"" + callbackUrl + "\">NEW TICKET</a>";
                msg.Destination = user.Email;
                msg.Subject     = "Invite to Household";
                await ems.SendMailAsync(msg);
            }
            catch (Exception ex)
            {
                await Task.FromResult(0);
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        public ActionResult ArchiveP(int ticketId, string userId)
        {
            var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticketId);
            var ticket    = db.Tickets.Find(ticketId);

            ticket.TicketStatusId = db.TicketStatuses.FirstOrDefault(t => t.Name == "Archived").Id;
            ticket.ArchivedById   = userId;

            ticket.Updated = DateTime.Now;
            db.SaveChanges();
            HistoryHelper.RecordHistory(oldTicket, ticket);
            db.SaveChanges();


            return(RedirectToAction("Details", "Tickets", new { id = ticketId }));
        }
Esempio n. 4
0
        public ActionResult Edit([Bind(Include = "Id,TicketTypeId,TicketStatusId,TicketPriorityId,AssignedToUserId,Title,Description, ProjectId")] Ticket ticket)
        {
            var status  = db.TicketStatuses.FirstOrDefault(t => t.Name == "Assigned").Id;
            var status2 = db.TicketStatuses.FirstOrDefault(t => t.Name == "Unassigned").Id;


            if (ModelState.IsValid)
            {
                var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id);

                db.Tickets.Attach(ticket);
                db.Entry(ticket).Property(x => x.TicketStatusId).IsModified   = true;
                db.Entry(ticket).Property(x => x.TicketTypeId).IsModified     = true;
                db.Entry(ticket).Property(x => x.TicketPriorityId).IsModified = true;
                db.Entry(ticket).Property(x => x.Title).IsModified            = true;
                db.Entry(ticket).Property(x => x.Description).IsModified      = true;
                db.Entry(ticket).Property(x => x.ProjectId).IsModified        = true;
                if (linkHelper.UserCanAssignTicket(ticket))
                {
                    db.Entry(ticket).Property(x => x.AssignedToUserId).IsModified = true;
                    ticket.TicketStatusId = status;
                    if (String.IsNullOrEmpty(ticket.AssignedToUserId))
                    {
                        ticket.TicketStatusId = status2;
                    }
                    //ticket.OwnerUserId = User.Identity.GetUserId();
                    db.SaveChanges();
                }


                ticket.Updated = DateTime.Now;
                db.SaveChanges();

                NotificationHelper.ManageNotifications(oldTicket, ticket);
                HistoryHelper.RecordHistory(oldTicket, ticket);
                return(RedirectToAction("Details", "Tickets", new { id = ticket.Id }));
            }
            ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "FirstName", ticket.AssignedToUserId);
            ViewBag.OwnerUserId      = new SelectList(db.Users, "Id", "FirstName", ticket.OwnerUserId);
            ViewBag.ProjectId        = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId);
            ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId);
            ViewBag.TicketStatusId   = new SelectList(db.TicketStatuses, "Id", "Name", ticket.TicketStatusId);
            ViewBag.TicketTypeId     = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId);
            return(View(ticket));
        }
Esempio n. 5
0
        public ActionResult Edit([Bind(Include = "Id,ProjectId,TicketTypeId,TicketStatusId,TicketPriorityId,OwnerUserId,AssignedToUserId,Title,Description,Created, Updated")] Ticket ticket)
        {
            if (ModelState.IsValid)
            {
                var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id);
                db.Tickets.Attach(ticket);
                db.Entry(ticket).Property(x => x.TicketStatusId).IsModified   = true;
                db.Entry(ticket).Property(x => x.TicketTypeId).IsModified     = true;
                db.Entry(ticket).Property(x => x.TicketPriorityId).IsModified = true;
                db.Entry(ticket).Property(x => x.Title).IsModified            = true;
                db.Entry(ticket).Property(x => x.Description).IsModified      = true;

                if (ticket.AssignedToUserId != null)
                {
                    db.Entry(ticket).Property(x => x.AssignedToUserId).IsModified = true;
                }
                ticket.Updated = DateTime.Now;
                db.SaveChanges();

                NotificationHelper.CreateAssignmentNotification(oldTicket, ticket);
                NotificationHelper.ManageNotifications(oldTicket, ticket);
                //HistoryHelper
                var historyHelper = new HistoryHelper();
                historyHelper.RecordHistory(oldTicket, ticket);

                return(RedirectToAction("MyIndex"));
            }
            //new edit ends
            ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "FirstName", ticket.AssignedToUserId);

            ViewBag.OwnerUserId      = new SelectList(db.Users, "Id", "FirstName", ticket.OwnerUserId);
            ViewBag.ProjectId        = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId);
            ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId);
            ViewBag.TicketStatusId   = new SelectList(db.TicketStatus, "Id", "StatusName", ticket.TicketStatusId);
            ViewBag.TicketTypeId     = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId);
            return(View(ticket));
        }