コード例 #1
0
        public async Task <ActionResult> Create(int TicketId, string AttachDescription, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                var ticketAttachment = new TicketAttachment
                {
                    Created     = DateTime.Now,
                    TicketId    = TicketId,
                    UserId      = User.Identity.GetUserId(),
                    Description = AttachDescription
                };
                var ticket = db.Tickets.Find(TicketId);
                if (AssetHelper.IsWebFriendlyImage(image))
                {
                    var filename = Path.GetFileName(image.FileName);
                    image.SaveAs(Path.Combine(Server.MapPath("~/Uploads/"), filename));
                    ticketAttachment.FilePath = "/Uploads/" + filename;
                }
                if (ticket.AssignedToUserId != null)
                {
                    TicketNotificationHelper NotificationHelper = new TicketNotificationHelper();
                    await NotificationHelper.SendNotificationAsync("File added ticket", "A attachment has been added to ticket", "Ticket Attachment", ticket.Id, ticket.AssignedToUserId);
                }

                db.TicketAttachments.Add(ticketAttachment);
                db.SaveChanges();
                return(RedirectToAction("Details", "Tickets", new { Id = TicketId }));
            }

            return(RedirectToAction("Details", "Tickets", new { Id = TicketId }));
        }
コード例 #2
0
        public ActionResult Edit([Bind(Include = "Id,Title,Description,Created,Updated,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusId,OwnerUserId,AssignedToUserId")] Ticket ticket)
        {
            if (ModelState.IsValid)
            {
                //db.Entry(ticket).State = EntityState.Modified;
                //db.SaveChanges();
                TicketHelper.Edit(ticket.Id, ticket.OwnerUserId, ticket.Title, ticket.Description, ticket.TicketTypeId, ticket.TicketPriorityId, ticket.TicketStatusId, ticket.AssignedToUserId);

                var modifiedTicket = db.Tickets.Find(ticket.Id);
                TicketNotificationHelper.AddNotification(modifiedTicket.Id, modifiedTicket.AssignedToUserId, NotificationType.ModifiedBy, User.Identity.GetUserName());
                db.SaveChanges();
                return(RedirectToAction("Index", new { userId = User.Identity.GetUserId() }));
                //return RedirectToAction("Index", "Projects", new { userId = User.Identity.GetUserId() });
            }

            string roleId     = db.Roles.FirstOrDefault(r => r.Name == "Developer").Id;
            var    developers = db.Users.Where(u => u.Roles.Any(r => r.RoleId == roleId));

            ViewBag.AssignedToUserId = new SelectList(developers, "Id", "Email", ticket.AssignedToUserId);
            //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));
        }
コード例 #3
0
        public ActionResult Assign(int Id, string AssignedToUserId)
        {
            TicketHelper.Assign(Id, AssignedToUserId);
            var developers          = UserHelper.GetUsersFromRole("Developer");
            var projectId           = db.Tickets.Find(Id).ProjectId;
            var developersOfProject = developers.Where(u => u.ProjectUsers.Any(pu => pu.ProjectId == projectId)).ToList();

            ViewBag.AssignedToUserId = new SelectList(developersOfProject, "Id", "Email");
            ViewBag.Id = Id;

            TicketNotificationHelper.AddNotification(Id, AssignedToUserId, NotificationType.AssignedBy, User.Identity.GetUserName());

            db.SaveChanges();
            db.Dispose();
            return(RedirectToAction("Index", "Projects", new { userId = User.Identity.GetUserId() }));
        }
コード例 #4
0
        public async Task <ActionResult> Create([Bind(Include = "TicketId,CommentBody")] TicketComment ticketComment)
        {
            if (ModelState.IsValid)
            {
                ticketComment.UserId  = User.Identity.GetUserId();
                ticketComment.Created = DateTime.Now;
                db.TicketComments.Add(ticketComment);
                db.SaveChanges();
                return(RedirectToAction("Details", "Tickets", new { Id = ticketComment.TicketId }));
            }

            var ticket = db.Tickets.Find(ticketComment.TicketId);
            TicketNotificationHelper NotificationHelper = new TicketNotificationHelper();
            await NotificationHelper.SendNotificationAsync("Comment added ticket", "A comment has been added to ticket", "Ticket Attachment", ticket.Id, ticket.AssignedToUserId);

            ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", ticketComment.TicketId);
            ViewBag.UserId   = new SelectList(db.Users, "Id", "FirstName", ticketComment.UserId);
            return(View(ticketComment));
        }