Example #1
0
        //Ticket Comments



        /// <summary>
        /// Administrators must be able to add Comments to any ticket
        /// </summary>
        /// <param name="ticket"></param>
        public void AddCommentToTicketForAdmin(TicketComments comment)
        {
            Ticket ticket = db.Tickets.Find(comment.TicketId);

            if (ticket == null)
            {
                return;
            }
            db.TicketComments.Add(comment);
            db.SaveChanges();
        }
Example #2
0
        //Submitters must be able to add Comments to tickets they own
        public void AddCommentToTicketForSubmitter(TicketComments comment, string userId)
        {
            Ticket ticket = db.Tickets.Find(comment.TicketId);

            if (ticket == null)
            {
                return;
            }
            if (ticket.OwenerUserId == userId)
            {
                db.TicketComments.Add(comment);
                db.SaveChanges();
            }
        }
Example #3
0
        /// <summary>
        ///Developers must be able to add Comments to tickets to which they are assigned
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="userId"></param>
        public void AddCommentToTicketForDeveloper(TicketComments comment, string userId)
        {
            Ticket ticket = db.Tickets.Find(comment.TicketId);

            if (ticket == null)
            {
                return;
            }
            if (ticket.AssignedToUserId == userId)
            {
                db.TicketComments.Add(comment);
                db.SaveChanges();
            }
        }
Example #4
0
        /// <summary>
        ///Project Managers must be able to add Comments to tickets belonging to Projects to which they are assigned
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="userId"></param>
        public void AddCommentToTicketForProjectManager(TicketComments comment, string userId)
        {
            Ticket ticket = db.Tickets.Find(comment.TicketId);

            if (ticket == null)
            {
                return;
            }
            var userProject = db.UserProjects.Where(x => x.ApplicationUserId == userId && x.ProjectId == comment.Ticket.ProjectId).FirstOrDefault();

            if (userProject != null)
            {
                db.TicketComments.Add(comment);
                db.SaveChanges();
            }
        }
Example #5
0
 /// <summary>
 /// Create ticket comments
 /// </summary>
 /// <param name="comments"></param>
 public void CreateTicketComment(TicketComments comments)
 {
     comments.Created = DateTime.Now;
     db.TicketComments.Add(comments);
     db.SaveChanges();
 }