Пример #1
0
        private TicketHistoryEntry UpdateDescription(string newValue, IPrincipal User, ApplicationDbContext context)
        {
            var history = new TicketHistoryEntry()
            {
                UserId = User.Identity.GetUserId(), ParentTicketId = this.Id, EntryType = TicketHistoryEntry.TicketHistoryEntryType.DescriptionModified, OldData = this.Description, NewData = newValue, OccuredAt = DateTime.Now
            };

            context.TicketNotifications.AddRange(
                TicketNotification.GenerateNotifications(context, User.Identity.GetUserId(), this.Id,
                                                         $"Description was updated (Length {( this.Description.Length - newValue.Length < 0 ? $"decreased by {( this.Description.Length - newValue.Length ) * -1}." : this.Description.Length - newValue.Length > 0 ? $"increased by {this.Description.Length - newValue.Length}." : "stayed the same." )}")
Пример #2
0
        private TicketHistoryEntry UpdateTitle(string newValue, IPrincipal User, ApplicationDbContext context)
        {
            var history = new TicketHistoryEntry()
            {
                UserId = User.Identity.GetUserId(), ParentTicketId = this.Id, EntryType = TicketHistoryEntry.TicketHistoryEntryType.TitleModified, OldData = this.Title, NewData = newValue, OccuredAt = DateTime.Now
            };

            context.TicketNotifications.AddRange(
                TicketNotification.GenerateNotifications(context, User.Identity.GetUserId(), this.Id, $"Title was updated from '{this.Title}' to '{newValue}'")
                );

            var ticket = context.Tickets.Find(this.Id);

            ticket.LastInteractionAt = DateTime.Now;
            ticket.Title             = newValue;

            context.SaveChanges();

            return(history);
        }