private static void PrepareTicketList(List <Ticket> tickets)
        {
            using (var ctx = new SolutionsContext())
            {
                var resources  = ctx.Resources.ToList();
                var statuses   = ctx.Statuses.ToList();
                var operations = ctx.Operations.ToList();
            }

            foreach (var ticket in tickets)
            {
                ticket.Author    = Employee.GetEmployee(ticket.AuthorId);
                ticket.Priority  = Priority.ById(ticket.PriorityId);
                ticket.Operation = Operation.ById(ticket.OperationId);
                ticket.Resource  = Resource.ById(ticket.OperationId);
                ticket.Status    = Status.ById(ticket.StatusId);

                if (ticket.TesterId != null)
                {
                    ticket.Tester = Employee.GetEmployee(ticket.TesterId);
                }
                if (ticket.ApproverId != null)
                {
                    ticket.Approver = Employee.GetEmployee(ticket.ApproverId);
                }
                if (ticket.PerformerId != null)
                {
                    ticket.Performer = Employee.GetEmployee(ticket.PerformerId);
                }

                ticket.ApproverComments  = Comment.ByType(ticket.Id, (int)Enums.CommentTypes.Approve);
                ticket.PerformerComments = Comment.ByType(ticket.Id, (int)Enums.CommentTypes.Perform);
            }
        }
        public ActionResult Reapprove(Ticket ticket, string comment)
        {
            if (!ModelState.IsValid)
            {
                var fullDesc      = ticket.FullDesc ?? null;
                var instructions  = ticket.Instructions ?? null;
                var technicalTask = ticket.TechnicalTask ?? null;

                var model = Ticket.ById(ticket.Id);
                Ticket.PrepareTicketToView(model);

                if (fullDesc != null)
                {
                    model.FullDesc = fullDesc;
                }
                if (instructions != null)
                {
                    model.Instructions = instructions;
                }
                if (technicalTask != null)
                {
                    model.TechnicalTask = technicalTask;
                }

                return(View("Edit", model));
            }

            Ticket.Reapprove(ticket, comment);
            if (comment != string.Empty)
            {
                var approveComments = Comment.ByType(ticket.Id, (int)Enums.CommentTypes.Approve);
                var lastCommentId   = approveComments.OrderBy(x => x.Date).Last().Id;
                Comment.Update(lastCommentId, comment);
            }

            return(RedirectToAction("RequestSent"));
        }