Exemple #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." )}")
Exemple #2
0
        public TicketHistoryEntry ArchiveTicket(IPrincipal User, ApplicationDbContext context)
        {
            TicketHistoryEntry output = null;

            if (this.TicketStatus.IsResolved && this.ParentProject.ActiveWorkflow.ArchivedResolvedStatusId != null)
            {
                output = this.UpdateStatus(this.ParentProject.ActiveWorkflow.ArchivedResolvedStatusId.Value, User, context, true, true);
            }
            else
            if (!this.TicketStatus.IsResolved && this.ParentProject.ActiveWorkflow.ArchivedNotResolvedStatusId != null)
            {
                output = this.UpdateStatus(this.ParentProject.ActiveWorkflow.ArchivedNotResolvedStatusId.Value, User, context, true, true);
            }

            return(output);
        }
Exemple #3
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);
        }