public void CreateDeleteTicketAttachment()
        {
            DepartmentCollection depts           = TestSetup.KayakoApiService.Departments.GetDepartments();
            StaffUserCollection  staff           = TestSetup.KayakoApiService.Staff.GetStaffUsers();
            StaffUser            randomStaffUser = staff[new Random().Next(staff.Count)];
            TicketCollection     tickets         = TestSetup.KayakoApiService.Tickets.GetTickets(depts.Select(d => d.Id).ToArray());
            Ticket randomTicket = tickets[new Random().Next(tickets.Count)];
            TicketPostCollection ticketPosts = TestSetup.KayakoApiService.Tickets.GetTicketPosts(randomTicket.Id);
            TicketPost           randomPost  = ticketPosts[new Random().Next(ticketPosts.Count)];

            string contents = Convert.ToBase64String(Encoding.UTF8.GetBytes("This is the file contents"));

            TicketAttachmentRequest request = new TicketAttachmentRequest()
            {
                TicketId     = randomTicket.Id,
                TicketPostId = randomPost.Id,
                FileName     = "TheFilename.txt",
                Contents     = contents
            };

            TicketAttachment createdAttachment = TestSetup.KayakoApiService.Tickets.AddTicketAttachment(request);

            Assert.AreEqual(createdAttachment.TicketId, randomTicket.Id);
            Assert.AreEqual(createdAttachment.TicketPostId, randomPost.Id);
            Assert.AreEqual(createdAttachment.FileName, "TheFilename.txt");
            //Assert.AreEqual(createdAttachment.Contents, contents);

            bool success = TestSetup.KayakoApiService.Tickets.DeleteTicketAttachment(randomTicket.Id, createdAttachment.Id);

            Assert.IsTrue(success);
        }
        public void CreateDeleteTicketPosts()
        {
            DepartmentCollection depts           = TestSetup.KayakoApiService.Departments.GetDepartments();
            StaffUserCollection  staff           = TestSetup.KayakoApiService.Staff.GetStaffUsers();
            StaffUser            randomStaffUser = staff[new Random().Next(staff.Count)];
            TicketCollection     tickets         = TestSetup.KayakoApiService.Tickets.GetTickets(depts.Select(d => d.Id).ToArray());
            Ticket randomTicket = tickets[new Random().Next(tickets.Count)];

            const string subject  = "New Post Subject";
            const string contents = "This will be the contents";

            TicketPostRequest request = new TicketPostRequest()
            {
                TicketId  = randomTicket.Id,
                Subject   = subject,
                Contents  = contents,
                StaffId   = randomStaffUser.Id,
                IsPrivate = false
            };

            TicketPost createdPost = TestSetup.KayakoApiService.Tickets.AddTicketPost(request);

            Assert.IsNotNull(createdPost);
            Assert.AreEqual(createdPost.StaffId, randomStaffUser.Id);
            //Assert.AreEqual(createdPost.Contents, String.Format("{0}\n{1}", contents, randomStaffUser.Signature));

            //Subject?

            bool success = TestSetup.KayakoApiService.Tickets.DeleteTicketPost(randomTicket.Id, createdPost.Id);

            Assert.IsTrue(success);
        }
Beispiel #3
0
        public ActionResult CreateTicket(TicketPost ticket)
        {
            //HelperMethod for Histories/Notifications
            var ticketCustomHelper = new TicketCustomHelper();
            //Variables
            var currentProject = db.Projects.Find(ticket.ProjectID);       //Current Project from the database.
            var formSubmitter  = db.Users.Find(User.Identity.GetUserId()); //User that submitted form
            var timeStamp      = DateTimeOffset.UtcNow;
            var newticket      = ticket;

            //####Start Access Control Section####
            var allowed = false;//Controls Access

            if (User.IsInRole("Admin"))
            {
                allowed = true;
            }
            else if (User.IsInRole("Project Manager") && currentProject.Users.Contains(formSubmitter))
            {
                allowed = true;
            }
            else if (User.IsInRole("Submitter") && currentProject.Users.Contains(formSubmitter))
            {
                allowed = true;
            }
            if (User.IsInRole("DemoAcc"))
            {
                allowed = false;
            }
            //####End Access Control Section####

            if (ModelState.IsValid && allowed == true)
            {
                newticket.OwnerUserID    = formSubmitter.Id;
                newticket.TicketStatusID = 3;
                newticket.Created        = timeStamp;
                db.TicketPosts.Add(newticket);
                db.SaveChanges();


                ticketCustomHelper.NewTicketNotification(currentProject, formSubmitter, timeStamp, newticket);
                if (User.IsInRole("Project Manager"))
                {
                    return(RedirectToAction("ManageProject", "BT", new { Id = currentProject.Id }));
                }
            }


            if (allowed == false)
            {
                string errcode = User.Identity.Name + " Permission not granted, CreateTicket, Project:" + currentProject.Id;
                return(RedirectToAction("Err403", "BT", new { errcode = errcode }));
            }

            return(RedirectToAction("ProjectDetails", "BT", new { id = currentProject.Id }));
        }
Beispiel #4
0
        public void GenericHistory(TicketPost oldTicket, string oldPropertyName, string newPropertyName, DateTimeOffset ticketUpdatedTimeStamp, ApplicationUser ticketEditor, string propertyChanged)
        {
            var newHistory = new TicketHistory();

            newHistory.TicketId        = oldTicket.Id;
            newHistory.UpdatedByUserId = ticketEditor.Id;
            newHistory.PropertyChanged = propertyChanged;
            newHistory.UpdatedTime     = ticketUpdatedTimeStamp;
            newHistory.OldAndNewValues = propertyChanged + " was changed From: " +
                                         oldPropertyName
                                         + "  To: " + newPropertyName;
            db.TicketHistories.Add(newHistory);
            db.SaveChanges();
        }
Beispiel #5
0
        //
        //History ############################################################
        //

        //Assignment History
        public void AssignmentHistory(TicketPost oldTicket, TicketPost newTicket, DateTimeOffset ticketUpdatedTimeStamp, ApplicationUser ticketEditor, string propertyChanged)
        {
            var newHistory = new TicketHistory();

            newHistory.TicketId        = oldTicket.Id;
            newHistory.UpdatedByUserId = ticketEditor.Id;
            newHistory.PropertyChanged = propertyChanged;
            newHistory.UpdatedTime     = ticketUpdatedTimeStamp;
            newHistory.OldAndNewValues = propertyChanged + " was changed From: " +
                                         ((oldTicket.AssignedToUserID != null) ? GetDisplayName(oldTicket.AssignedToUserID) : "Unassigned")
                                         + "  To: " + GetDisplayName(newTicket.AssignedToUserID);
            db.TicketHistories.Add(newHistory);
            db.SaveChanges();
        }
        public void GetTicketPost()
        {
            DepartmentCollection depts   = TestSetup.KayakoApiService.Departments.GetDepartments();
            TicketCollection     tickets = TestSetup.KayakoApiService.Tickets.GetTickets(depts.Select(d => d.Id).ToArray());
            Ticket randomTicket          = tickets[new Random().Next(tickets.Count)];

            TicketPostCollection ticketPosts = TestSetup.KayakoApiService.Tickets.GetTicketPosts(randomTicket.Id);

            Assert.IsNotNull(ticketPosts, "No ticket posts were returned for ticket id " + randomTicket.Id);
            Assert.IsNotEmpty(ticketPosts, "No ticket posts were returned for ticket id " + randomTicket.Id);

            TicketPost randomTicketPostToGet = ticketPosts[new Random().Next(ticketPosts.Count)];

            Trace.WriteLine("GetTicketPost using ticket post id: " + randomTicketPostToGet.Id);

            TicketPost ticketPriority = TestSetup.KayakoApiService.Tickets.GetTicketPost(randomTicket.Id, randomTicketPostToGet.Id);

            CompareTicketPost(ticketPriority, randomTicketPostToGet);
        }
        public static void CompareTicketPost(TicketPost one, TicketPost two)
        {
            Assert.AreEqual(one.Contents, two.Contents);
            Assert.AreEqual(one.Creator, two.Creator);
            Assert.AreEqual(one.Dateline, two.Dateline);
            Assert.AreEqual(one.Email, two.Email);
            Assert.AreEqual(one.EmailTo, two.EmailTo);
            Assert.AreEqual(one.FullName, two.FullName);
            Assert.AreEqual(one.HasAttachments, two.HasAttachments);
            Assert.AreEqual(one.Id, two.Id);
            Assert.AreEqual(one.IPAddress, two.IPAddress);
            Assert.AreEqual(one.IsEmailed, two.IsEmailed);
            Assert.AreEqual(one.IsHtml, two.IsHtml);
            Assert.AreEqual(one.IsSurveyComment, two.IsSurveyComment);
            Assert.AreEqual(one.IsThirdParty, two.IsThirdParty);
            Assert.AreEqual(one.StaffId, two.StaffId);
            Assert.AreEqual(one.UserId, two.UserId);

            AssertObjectXmlEqual <TicketPost>(one, two);
        }
Beispiel #8
0
        //
        //Notifications ######################################################
        //

        //Assignment Notification
        public void AssignmentNotification(TicketPost oldTicket, TicketPost editedTicket, DateTimeOffset ticketUpdatedTimeStamp, ApplicationUser ticketEditor)
        {
            if (oldTicket.AssignedToUserID != null)
            {
                var newTicketNotification = new TicketNotification();
                newTicketNotification.Notification =
                    " Assigned Ticket # " + oldTicket.Id + " to " + GetDisplayName(editedTicket.AssignedToUserID);
                newTicketNotification.TriggeredByUserId = ticketEditor.Id;
                newTicketNotification.TicketID          = oldTicket.Id;
                newTicketNotification.Created           = ticketUpdatedTimeStamp;
                newTicketNotification.UserID            = oldTicket.AssignedToUserID;
                db.TicketNotifications.Add(newTicketNotification);
            }

            //Notification for new Assignee
            var newTicketNotification2 = new TicketNotification();

            newTicketNotification2.Notification =
                " Assigned Ticket # " + oldTicket.Id + " to you.";
            newTicketNotification2.TriggeredByUserId = ticketEditor.Id;
            newTicketNotification2.TicketID          = oldTicket.Id;
            newTicketNotification2.Created           = ticketUpdatedTimeStamp;
            newTicketNotification2.UserID            = editedTicket.AssignedToUserID;
            db.TicketNotifications.Add(newTicketNotification2);

            //Notify Owner
            var newTicketNotification3 = new TicketNotification();

            newTicketNotification3.Notification =
                " The Ticket # " + oldTicket.Id + " that you own, has been assigned to " + GetDisplayName(editedTicket.AssignedToUserID);
            newTicketNotification3.TriggeredByUserId = ticketEditor.Id;
            newTicketNotification3.TicketID          = oldTicket.Id;
            newTicketNotification3.Created           = ticketUpdatedTimeStamp;
            newTicketNotification3.UserID            = db.TicketPosts.Find(oldTicket.Id).OwnerUserID;
            db.TicketNotifications.Add(newTicketNotification3);
            //Save Ticket Notification(s)
            db.SaveChanges();
        }
Beispiel #9
0
        public ActionResult CreateTicket(HttpPostedFileBase file, TicketPost requestPost)
        {
            if (!ModelState.IsValid)
            {
                var message = string.Join(" | ", ModelState.Values
                                          .SelectMany(v => v.Errors)
                                          .Select(e => e.ErrorMessage));
                Session["Error"] = message;
                return(RedirectToAction("Ticket"));
            }

            //save  ticket
            Ticket ticketParam = new Ticket();
            string name        = null;
            string email       = null;
            string phone       = null;

            ticketParam.Title         = requestPost.Title;
            ticketParam.Message       = requestPost.Message;
            ticketParam.TicketId      = RandomNumber() + RandomNumber();
            ticketParam.Id            = ticketParam.TicketId;
            ticketParam.SourceData    = requestPost.type;
            ticketParam.Ticket_Status = 1;
            ticketParam.IGR_Code      = Session["igr"].ToString();
            ticketParam.Created_at    = DateTime.Now;
            if (Session["temporary_tin"] == null)
            {
                ticketParam.TinId = Session["tinNo"].ToString();
                name  = Session["name"].ToString();
                email = Session["email"].ToString();
                phone = Session["phone"].ToString();
            }
            else
            {
                ticketParam.TinId = Session["temporary_tin"].ToString();
                name  = Session["name"].ToString();
                email = Session["email"].ToString();
                phone = Session["phone"].ToString();
            }



            try
            {
                var ticketPara = db.Ticket.Add(ticketParam);
                db.SaveChanges();

                if (ticketPara != null)
                {
                    EmailParam param = new EmailParam();
                    param.Email       = "*****@*****.**";
                    param.SenderEmail = "*****@*****.**";
                    param.From        = "Open Ticket for IGR";
                    param.Message     = "Hi Admin,\n\nYou have a pending ticket with content below\n\nPlease login into support to respond ticket\n\n--------------\n\n"
                                        + requestPost.Message + "\n\n------------\n\nSender Name: " + name + "\nTinNo: " + ticketParam.TinId +
                                        "\nPhone: " + phone + "\nEmaill: " + email;
                    EmailClass.sendEmail(EMAILAPI, param);
                }
            }
            catch (Exception ex)
            {
                Session["Error"] = ex.Message.ToString();
                return(RedirectToAction("Ticket"));
            }


            foreach (string upload in Request.Files)
            {
                if (Request.Files[upload].ContentLength > 0)
                {
                    var filename = ticketParam.TicketId + ".png";
                    var size     = Request.Files[upload].ContentLength;

                    if (size > 532000)
                    {
                        Session["Error"] = "File cannot be larger than 500KB";
                        return(RedirectToAction("Ticket"));
                    }
                    var FileExt = Request.Files[upload].ContentType;
                    if (FileExt == "image/png" || FileExt == "image/jpeg")
                    {
                        var    filePathOriginal  = Server.MapPath("/Content/img");
                        var    filePathThumbnail = Server.MapPath("/Content/img");
                        string savedFileName     = Path.Combine(filePathOriginal, filename);
                        Request.Files[upload].SaveAs(savedFileName);
                    }
                    else
                    {
                        Session["Error"] = "Please upload a .png or .jpeg format";
                        return(RedirectToAction("Ticket"));
                    }
                }
            }

            Session["Sucess"] = "Ticket successfully opened";
            return(RedirectToAction("Ticket"));
        }
Beispiel #10
0
        public void NewTicketNotification(Projects currentProject, ApplicationUser formSubmitter, DateTimeOffset timeStamp, TicketPost newticket)
        {
            //UserRoles Helper
            var userRolesHelper          = new UserRolesHelper(db);
            var project                  = db.Projects.Find(currentProject.Id);
            var allProjectManagers       = userRolesHelper.GetAllUsersInRole("Project Manager").ToList();
            var projectManagersInProject = allProjectManagers.Where(u => u.Projects.Contains(project)).ToList();

            //Notify all PMs that a new ticket has been created on their Project
            foreach (var item in projectManagersInProject)
            {
                var newTicketNotification = new TicketNotification();
                newTicketNotification.Notification =
                    " Has added a New Ticket(#" + newticket.Id + ") on Project(#" + currentProject.Id + "): " + currentProject.Name +
                    ", Ticket Priority: " + GetPriorityName(newticket.TicketPriorityID);
                newTicketNotification.TriggeredByUserId = formSubmitter.Id;
                newTicketNotification.TicketID          = newticket.Id;
                newTicketNotification.Created           = timeStamp;
                newTicketNotification.UserID            = item.Id;
                db.TicketNotifications.Add(newTicketNotification);
                //Save Ticket Notification
                db.SaveChanges();
            }
        }
Beispiel #11
0
        public ActionResult EditTicketForm([Bind(Include = "Id,Created,Updated,Title,Description,ProjectID,TicketStatusID,TicketTypeID,TicketPriorityID,OwnerUserID,AssignedToUserID")] TicketPost ticketPost)
        {
            if (ModelState.IsValid)
            {
                //HelperMethod for Histories/Notifications
                var ticketCustomHelper = new TicketCustomHelper();

                var currentTicket          = db.TicketPosts.Find(ticketPost.Id);       //Current Ticket from the database.
                var editedTicket           = ticketPost;                               //Changes that were submitted through Form Post
                var allUsers               = db.Users;
                var ticketEditor           = db.Users.Find(User.Identity.GetUserId()); //User that edited the ticket
                var ticketUpdatedTimeStamp = DateTimeOffset.UtcNow;                    //Used so ticket updated-date/history-time/notificaiton-time
                var changesMade            = false;                                    //is used to control one final saved of all ticket edits
                var updateNoftication      = false;                                    //is used to control & send one generic edit message
                db.TicketPosts.Attach(currentTicket);                                  //Sets currentTicket ready for changes.

                //####Start Access Control Section####
                var allowed = false;//Controls Access
                if (User.IsInRole("Admin"))
                {
                    allowed = true;
                }
                else if (User.IsInRole("Project Manager") && currentTicket.Project.Users.Contains(ticketEditor))
                {
                    allowed = true;
                }
                else if (User.IsInRole("Developer") && currentTicket.AssignedToUser != null)
                {
                    if (currentTicket.AssignedToUser == ticketEditor)
                    {
                        allowed = true;
                    }
                }
                else if (User.IsInRole("Submitter") && currentTicket.OwnerUser == ticketEditor)
                {
                    allowed = true;
                }
                if (User.IsInRole("DemoAcc"))
                {
                    allowed = false;
                }
                //####End Access Control Section####

                //ONLY Editable Items   - Details/Overview of each section.
                //  AssignedToUserID    - PM Only, Creates History Entry, Sends Notification to new asignee & old assignee.
                //  TicketPriorityID    -  Creates History Entry, Sends generic Notification
                //  TicketTypeID        -  Creates History Entry, Sends generic Notification
                //  TicketStatusID      -  Creates History Entry, Sends generic Notification
                //  Description         -  Creates History Entry, Sends generic Notification
                //  Title               -  Creates History Entry, Sends generic Notification

                if (allowed)
                {
                    if (currentTicket.AssignedToUserID != editedTicket.AssignedToUserID && User.IsInRole("Project Manager"))
                    {
                        //Create Ticket Assignment History, Create Ticket Assignment Notifications, Set ticket property change
                        ticketCustomHelper.AssignmentHistory(currentTicket, editedTicket, ticketUpdatedTimeStamp, ticketEditor, "Assignment"); //History
                        ticketCustomHelper.AssignmentNotification(currentTicket, editedTicket, ticketUpdatedTimeStamp, ticketEditor);          //Notification
                        currentTicket.AssignedToUserID = editedTicket.AssignedToUserID;                                                        //set ticket edit change
                        changesMade = true;
                    }

                    if (currentTicket.TicketPriorityID != editedTicket.TicketPriorityID)
                    {
                        //Create Ticket History, Set Ticket Edit Change
                        var editedPropertyName = ticketCustomHelper.GetPriorityName(editedTicket.TicketPriorityID); //Get ticket priority name
                        ticketCustomHelper.GenericHistory(currentTicket, currentTicket.TicketPriority.Name, editedPropertyName, ticketUpdatedTimeStamp, ticketEditor, "Ticket Priority");
                        currentTicket.TicketPriorityID = editedTicket.TicketPriorityID;                             //Set Ticket Edit Change
                        changesMade       = true;
                        updateNoftication = true;
                    }
                    if (currentTicket.TicketTypeID != editedTicket.TicketTypeID)
                    {
                        //Create Ticket History, Set Ticket Edit Change
                        var editedPropertyName = ticketCustomHelper.GetTypeName(editedTicket.TicketTypeID);                                                                       //Get ticket type name
                        ticketCustomHelper.GenericHistory(currentTicket, currentTicket.TicketType.Name, editedPropertyName, ticketUpdatedTimeStamp, ticketEditor, "Ticket Type"); //History
                        currentTicket.TicketTypeID = editedTicket.TicketTypeID;                                                                                                   //Set Ticket Edit Change
                        changesMade       = true;
                        updateNoftication = true;
                    }
                    if (currentTicket.TicketStatusID != editedTicket.TicketStatusID)
                    {
                        //Create Ticket History, Set Ticket Edit Change
                        var editedPropertyName = ticketCustomHelper.GetStatusName(editedTicket.TicketStatusID);                                                                       //Get ticket priority name
                        ticketCustomHelper.GenericHistory(currentTicket, currentTicket.TicketStatus.Name, editedPropertyName, ticketUpdatedTimeStamp, ticketEditor, "Ticket Status"); //History
                        currentTicket.TicketStatusID = editedTicket.TicketStatusID;                                                                                                   //Set Ticket Edit Change
                        changesMade       = true;
                        updateNoftication = true;
                    }
                    if (currentTicket.Description != editedTicket.Description)
                    {
                        //Create Ticket History, Set Ticket Edit Change
                        ticketCustomHelper.GenericHistory(currentTicket, currentTicket.Description, editedTicket.Description, ticketUpdatedTimeStamp, ticketEditor, "Ticket Description"); //History
                        currentTicket.Description = editedTicket.Description;                                                                                                              //Set Ticket Edit Change
                        changesMade       = true;
                        updateNoftication = true;
                    }
                    if (currentTicket.Title != editedTicket.Title)
                    {
                        //Create Ticket History, Set Ticket Edit Change
                        ticketCustomHelper.GenericHistory(currentTicket, currentTicket.Title, editedTicket.Title, ticketUpdatedTimeStamp, ticketEditor, "Ticket Title"); //History
                        currentTicket.Title = editedTicket.Title;                                                                                                        //Set Ticket Edit Change
                        changesMade         = true;
                        updateNoftication   = true;
                    }

                    if (changesMade)
                    {
                        //Sends Nofitication to Ticket Asignee. (Not when Assignee is changed)
                        //(Nofication for Asignee change is sent in the Assignment section above)
                        if (updateNoftication)
                        {
                            ticketCustomHelper.GenericTicketChangeNotification(currentTicket.AssignedToUserID, ticketEditor, currentTicket.Id, ticketUpdatedTimeStamp);
                        }
                        //Set time/editor, and save changes.
                        currentTicket.UpdatedByUserID = ticketEditor.Id;
                        currentTicket.Updated         = ticketUpdatedTimeStamp;
                        db.SaveChanges();
                    }
                    return(RedirectToAction("Ticket", "BT", new { id = currentTicket.Id }));
                }
                if (allowed == false)
                {
                    string errcode = User.Identity.Name + " Permission not granted, TicketEditForm, Ticket: " + currentTicket.Id;
                    return(RedirectToAction("Err403", "BT", new { errcode = errcode }));
                }
            }

            return(RedirectToAction("Ticket", "BT", new { id = ticketPost.Id }));
        }
Beispiel #12
0
        public ActionResult Ticket(int Id)
        {
            //UserRoles Helper
            var userRolesHelper = new UserRolesHelper(db);
            //Get Ticket & Instantiate Model
            var ticket      = db.TicketPosts.Find(Id);
            var currentUser = db.Users.Find(User.Identity.GetUserId());
            var TicketPost  = new TicketPost();

            TicketPost = ticket;

            if (currentUser == ticket.AssignedToUser || currentUser == ticket.OwnerUser || User.IsInRole("Project Manager") || User.IsInRole("Admin") || ticket.Project.Users.Contains(currentUser))
            {
            }
            else
            {
                string errcode = "Access Denied, Ticket ( #" + ticket.Id.ToString() + " ) User:"******"Err403", "BT", new { errcode = errcode }));
            }

            //Set Dropdowns for edit tab.
            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);
            var    allDevelopers       = userRolesHelper.GetAllUsersInRole("Developer").OrderBy(u => u.DisplayName);
            var    developersInProject = allDevelopers.Where(u => u.Projects.Contains(ticket.Project));
            string assignedUser;

            if (ticket.AssignedToUserID == null)
            {
                assignedUser = "******";
            }
            else
            {
                assignedUser = ticket.AssignedToUserID;
            }
            ViewBag.AssignedToUserID = new SelectList(developersInProject, "Id", "DisplayName", assignedUser);

            //Data for TicketHistories
            var ticketHistory     = TicketPost.TicketHistories.OrderByDescending(x => x.UpdatedTime).ToList();
            var historyTimesList  = ticketHistory.Select(x => x.UpdatedTime).Distinct().ToList();
            var ticketHistoryList = new List <TicketHistory>().ToArray();


            var TopList = new List <TopDispHist>();

            foreach (var item in historyTimesList)
            {
                var TopDispHist = new TopDispHist();
                TopDispHist.HistEntriesList = new List <TicketHistory>();

                var ticketEntry = ticketHistory.Where(t => t.UpdatedTime == item);
                TopDispHist.HistEntriesList.AddRange(ticketEntry.ToList());
                TopDispHist.Created     = item;
                TopDispHist.DisplayName = TopDispHist.HistEntriesList.First().UpdatedByUser.DisplayName;
                TopList.Add(TopDispHist);
            }

            ViewData["ticketHistoryList"] = (List <TopDispHist>)TopList;
            ViewBag.TopDisp = (List <TopDispHist>)TopList;

            //Get Comments for ticket
            var commentList = ticket.TicketComments.OrderByDescending(c => c.Created).ToList();

            ViewData["CommentList"] = (List <TicketComment>)commentList;

            //For Attachment Partial - May not need.
            ViewData["currentTicket"] = (TicketPost)ticket;

            if (User.IsInRole("Admin") || User.IsInRole("Project Manager"))
            {
                return(View(TicketPost));
            }
            if (ticket.Project.Users.Contains(currentUser))
            {
                return(View(TicketPost));
            }
            else
            {
                string errcode = User.Identity.Name + " Permission not granted, ViewTicket, Ticket:" + ticket.Id;
                return(RedirectToAction("Err403", "BT", new { errcode = errcode }));
            }
        }