コード例 #1
0
ファイル: TicketController.cs プロジェクト: jzca/BugTracker
        private void CreateHistory(Ticket ticket, HistoryProperty historyProperty,
                                   bool changeDetected, string userId, string oldValue, string newValue)
        {
            if (changeDetected)
            {
                var freshHistory = new TicketHistory()
                {
                    TicketId   = ticket.Id,
                    ModifierId = userId,
                    Property   = historyProperty.ToString(),
                    TimeStamp  = DateTime.Now,
                };

                if (historyProperty == HistoryProperty.ProjectBelong)
                {
                    var realOldValue = ticket.Project.Name;
                    var inputId      = Convert.ToInt32(newValue);
                    var realNewValue = AppHepler.GetProjectById(inputId).Name;

                    AddValueHistory(realOldValue, realNewValue, freshHistory);
                }
                else if (historyProperty == HistoryProperty.TicketDescription)
                {
                    AddValueHistory(oldValue, newValue, freshHistory);
                }
                else if (historyProperty == HistoryProperty.TicketPriority)
                {
                    var realOldValue = ticket.TicketPriority.Name;
                    var inputId      = Convert.ToInt32(newValue);
                    var realNewValue = AppHepler.GetTkPriorityById(inputId).Name;
                    AddValueHistory(realOldValue, realNewValue, freshHistory);
                }
                else if (historyProperty == HistoryProperty.TicketStatus)
                {
                    var realOldValue = ticket.TicketStatus.Name;
                    var inputId      = Convert.ToInt32(newValue);
                    var realNewValue = AppHepler.GetTkStatusById(inputId).Name;
                    AddValueHistory(realOldValue, realNewValue, freshHistory);
                }
                else if (historyProperty == HistoryProperty.TicketType)
                {
                    var realOldValue = ticket.TicketType.Name;
                    var inputId      = Convert.ToInt32(newValue);
                    var realNewValue = AppHepler.GetTkTypeyById(inputId).Name;
                    AddValueHistory(realOldValue, realNewValue, freshHistory);
                }
                else if (historyProperty == HistoryProperty.TicketTitle)
                {
                    AddValueHistory(oldValue, newValue, freshHistory);
                }
                else if (historyProperty == HistoryProperty.Assignee)
                {
                    AddValueHistory(oldValue, newValue, freshHistory);
                }

                DbContext.TicketHistories.Add(freshHistory);

                DbContext.SaveChanges();
            }
        }
コード例 #2
0
 SetValue(HistoryProperty, value);