public static ActivityHistoryItem FromDto(ActivityHistoryItemDto dto) { var retVal = new ActivityHistoryItem(); retVal.UpdateFromDto(dto); return(retVal); }
public void UpdateFromDto(ActivityDto dto) { this.Guid = dto.Guid; this.Name = dto.Name; this.ActivityListGuid = dto.ActivityListGuid; this.GoalGuid = dto.GoalGuid; this.ActiveDueDate = dto.ActiveDueDate; if (dto.LeadTime == null) { this.LeadTime = null; } else { this.LeadTime = new DateProjection(); this.LeadTime.UpdateFromDto(dto.LeadTime); } if (dto.Recurrence == null) { this.Recurrence = null; } else { this.Recurrence = new DateRecurrence(); this.Recurrence.UpdateFromDto(dto.Recurrence); } this.CompletionHistory = new List <ActivityHistoryItem>(); foreach (ActivityHistoryItemDto historyItemDto in dto.CompletionHistory) { this.CompletionHistory.Add(ActivityHistoryItem.FromDto(historyItemDto)); } }
public static ActivityHistoryItemDto ToDto(ActivityHistoryItem model) { var retVal = new ActivityHistoryItemDto(); model.UpdateDto(retVal); return(retVal); }
public void UpdateDto(ActivityDto dto) { dto.Guid = this.Guid; dto.Name = this.Name; dto.ActivityListGuid = this.ActivityListGuid; dto.GoalGuid = this.GoalGuid; dto.ActiveDueDate = this.ActiveDueDate; if (this.LeadTime == null) { dto.LeadTime = null; } else { dto.LeadTime = new DateProjectionDto(); this.LeadTime.UpdateDto(dto.LeadTime); } if (this.Recurrence == null) { dto.Recurrence = null; } else { dto.Recurrence = new DateRecurrenceDto(); this.Recurrence.UpdateDto(dto.Recurrence); } dto.CompletionHistory = new List <ActivityHistoryItemDto>(); foreach (ActivityHistoryItem historyItem in this.CompletionHistory) { dto.CompletionHistory.Add(ActivityHistoryItem.ToDto(historyItem)); } }
public static void ResetActiveDueDateFromLastHistoryItem(this Activity activity) { if (activity.CompletionHistory.Any()) { ActivityHistoryItem historyItem = activity.CompletionHistory.Last(); activity.ActiveDueDate = historyItem.DueDate == null && activity.Recurrence.RecurFromType == ERecurFromType.FromActiveDueDate ? null : activity.Recurrence?.GetNext(historyItem.DueDate ?? DateTime.MaxValue, historyItem.CompletedDate, activity.CompletionHistory.Count); } }