Beispiel #1
0
        private void AddItems(List <ToDoItemModel> items)
        {
            var minDate = DateTime.MinValue.AddYears(DateTime.Now.Year);

            foreach (var i in items)
            {
                var itemView = new ToDoItemView
                {
                    Id          = i.Id,
                    Header      = i.Header,
                    Notes       = i.Notes,
                    Date        = i.Date,
                    Deadline    = i.Deadline,
                    CompleteDay = i.CompleteDay,
                    ProjectId   = i.ProjectId,
                    ProjectName = i.ProjectName,
                    Timer       = i.Timer
                };

                if (i.Deadline == minDate)
                {
                    ToDoItems.Add(itemView);
                    continue;
                }

                if (i.Deadline <= DateTime.Today)
                {
                    itemView.DeadlineColor = "Red";
                    itemView.DeadlineShort = "today";
                }
                else
                {
                    var remainingDays = (i.Deadline - DateTime.Today).TotalDays;

                    itemView.DeadlineColor = "Gray";
                    itemView.DeadlineShort = $"{remainingDays}d left";
                }

                ToDoItems.Add(itemView);
            }
        }
Beispiel #2
0
 protected override bool IsCorrect(ToDoItemView item)
 {
     return(true);
 }
Beispiel #3
0
 protected override bool IsCorrect(ToDoItemView item)
 {
     // User didn't choose a date for task.
     return(item.Date == MinDate);
 }
Beispiel #4
0
 protected override bool IsCorrect(ToDoItemView item)
 {
     // User chose today's date for task.
     return(item.Date <= DateTime.Today && item.Date != MinDate ||
            item.Deadline <= DateTime.Today && item.Deadline != MinDate);
 }
Beispiel #5
0
 protected abstract bool IsCorrect(ToDoItemView item);