Пример #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);
            }
        }
Пример #2
0
 protected override bool IsCorrect(ToDoItemView item)
 {
     return(true);
 }
Пример #3
0
 protected override bool IsCorrect(ToDoItemView item)
 {
     // User didn't choose a date for task.
     return(item.Date == MinDate);
 }
Пример #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);
 }
Пример #5
0
 protected abstract bool IsCorrect(ToDoItemView item);