Exemplo n.º 1
0
 public Ticket Update(Ticket ticket, ref List <ChangeLog> changeLogs)
 {
     using (var context = new PunchClockDbContext())
     {
         var entity = context.Tickets.FirstOrDefault(x => x.Id == ticket.Id);
         if (entity == null)
         {
             return(ticket);
         }
         entity.Title           = ticket.Title;
         entity.ProjectId       = ticket.ProjectId;
         entity.PriorityId      = ticket.PriorityId;
         entity.Description     = ticket.Description;
         entity.StatusId        = ticket.StatusId;
         entity.TypeId          = ticket.TypeId;
         entity.RequestorId     = ticket.RequestorId;
         entity.AssignedToId    = ticket.AssignedToId;
         entity.NotifyTo        = ticket.NotifyTo;
         entity.CategoryId      = ticket.CategoryId;
         entity.EstimatedEffort = ticket.EstimatedEffort;
         entity.CompletedWork   = ticket.CompletedWork;
         if (ticket.DueDateUtc.HasValue)
         {
             entity.DueDateUtc = ticket.DueDateUtc.Value.ToUniversalTime();
         }
         if (ticket.Comments != null && ticket.Comments.Any())
         {
             context.TicketComments.AddOrUpdate(ticket.Comments.ToArray());
         }
         changeLogs = context.GetEntityChanges();
         context.SaveChanges();
     }
     return(ticket);
 }