Exemple #1
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Title,Description,Created,Updated,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusId,OwnerUserId,AssignedToUserId")] Tickets tickets)
        {
            var th       = new TicketsHelper(urh, db);
            var OGticket = db.Ticket.AsNoTracking().First(t => t.Id == tickets.Id);

            if (ModelState.IsValid)
            {
                //tickets.AssignedToUserId = Developer;
                db.Entry(tickets).State = EntityState.Modified;

                db.SaveChanges();

                var newTicket = db.Ticket.AsNoTracking().First(t => t.Id == tickets.Id);

                th.AddTicketHistory(OGticket, newTicket, User.Identity.GetUserId());

                var nh = new NotificationsHelper();
                await nh.HandleNotifications(OGticket, newTicket);

                return(RedirectToAction("Index"));
            }

            ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "DisplayName", tickets.AssignedToUserId);
            ViewBag.OwnerUserId      = new SelectList(db.Users, "Id", "DisplayName", tickets.OwnerUserId);
            ViewBag.ProjectId        = new SelectList(db.Project, "Id", "Name", tickets.ProjectId);
            ViewBag.TicketPriorityId = new SelectList(db.TicketPriority, "Id", "Name", tickets.TicketPriorityId);
            ViewBag.TicketStatusId   = new SelectList(db.TicketStatus, "Id", "Name", tickets.TicketStatusId);
            ViewBag.TicketTypeId     = new SelectList(db.TicketType, "Id", "Name", tickets.TicketTypeId);

            var developers = urh.UsersInRole("Developer");

            ViewBag.Developer = new MultiSelectList(urh.UsersInRole("Developer"), "Id", "DisplayName");

            return(View(tickets));
        }