示例#1
0
 public static bool AddTask(List<Task> tasks, Task t)
 {
     //TODO: Replace with a post to a server
     bool added = false;
     if (tasks != null)
     {
         tasks.Add(t);
         added = true;
     }
     else { throw new ArgumentNullException("tasks", "task cannot be added to a null list"); }
     return added;
 }
示例#2
0
        public static Section[] CreateTaskDetailSections(Task task)
        {
            List<Section> sections = new List<Section>();

            // additional info
            var detailSection = new Section();
            sections.Add(detailSection);

            string dateValue = task.Date.ToShortTimeString();
            detailSection.Add(new StringElement("Date", dateValue));
            detailSection.Add(new StyledMultilineElement("Description", task.Description));
            return sections.ToArray();
        }
        public static Section[] BuildDialogSections(Task t)
        {
            // init to default values
            DateTime date = DateTime.Now;
            string description = null;

            // update values if a contact was passed in
            if (t != null)
            {
                date = t.Date;
                if (!string.IsNullOrEmpty(t.Description)) description = t.Description;
            }

            // build dialog section
            var name = new Section();
            name.Add(new DateTimeElement("Date", date));
            name.Add(new MultiLineEntrySubTextItem("Description", description ?? string.Empty, true) { Rows = 4 });

            return new Section[] { name };
        }
示例#4
0
        public static bool UpdateTask(IEnumerable<Task> tasks, Task task)
        {
            bool updated = false;
            if (tasks != null)
            {
                foreach(Task t in tasks)
                {
                    if (t.Id == task.Id)
                    {
                        t.Date = task.Date;
                        t.Description = task.Description;

                        updated = true;
                        break;
                    }
                }
            }
            else { throw new ArgumentNullException("tasks", "task cannot be updated in a null list"); }
            return updated;
        }
        public static bool SaveDialogElementsToModel(Task t, Section[] s)
        {
            if (s != null)
            {
                foreach (Element el in s[0])
                {
                    if (el.Caption == "Date")
                    {
                        string dateValue = ((DateTimeElement)el).Value;
                        t.Date = Convert.ToDateTime(dateValue);
                    }
                    else if (el.Caption == "Description")
                    {
                        t.Description = ((MultiLineEntrySubTextItem)el).Value;
                    }
                }
            }

            //TODO: Refactor method to void if it can't fail
            return true;
        }