//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(); }
//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(); } }
/// <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(); } }
/// <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(); } }
/// <summary> /// Create ticket comments /// </summary> /// <param name="comments"></param> public void CreateTicketComment(TicketComments comments) { comments.Created = DateTime.Now; db.TicketComments.Add(comments); db.SaveChanges(); }