Exemplo n.º 1
0
        public static void UpdateDependentTasks(string id, string parentid)
        {
            ToDoService.ToDoItemContract toDoItem = new ToDoService.ToDoItemContract();
            toDoItem.Id       = id;
            toDoItem.ParentId = parentid;

            UpdateDependentTasks(toDoItem);
        }
Exemplo n.º 2
0
        protected void btn_AddTask_Click(object sender, EventArgs e)
        {
            ToDoService.ToDoItemContract toDoItem = new ToDoService.ToDoItemContract();
            toDoItem.Title       = txtTask.Text;
            toDoItem.Description = txtDescription.Text;

            Save(toDoItem);

            // update the UI
            LoadTasks();
        }
Exemplo n.º 3
0
        protected void dlTasks_UpdateCommand(Object sender, DataListCommandEventArgs e)
        {
            ToDoService.ToDoItemContract toDoItem = new ToDoService.ToDoItemContract();
            toDoItem.Id          = e.CommandArgument.ToString();
            toDoItem.Title       = (e.Item.FindControl("txtUpdateTitle") as TextBox).Text;
            toDoItem.Description = (e.Item.FindControl("txtUpdateDescription") as TextBox).Text;
            toDoItem.Complete    = (e.Item.FindControl("chkComplete") as CheckBox).Checked;

            Save(toDoItem);

            // take the list out of edit mode
            dlTasks.EditItemIndex = -1;

            // update the UI
            LoadTasks();
        }
Exemplo n.º 4
0
        private static void UpdateDependentTasks(ToDoService.ToDoItemContract toDoItemContract)
        {
            ToDoService.ToDoServiceClient client = new ToDoService.ToDoServiceClient();

            try
            {
                // update the task
                client.UpdateDependentTasks(toDoItemContract);
            }
            catch (Exception ex)
            {
                client.Abort();
                // TODO: Client side save error message
                return;
            }
        }
Exemplo n.º 5
0
        private string Save(ToDoService.ToDoItemContract toDoItemContract)
        {
            // get the todo list items
            ToDoService.ToDoServiceClient client = new ToDoService.ToDoServiceClient();

            try
            {
                // save the new task
                return(client.SaveToDoItem(toDoItemContract));
            }
            catch (Exception ex)
            {
                client.Abort();
                // TODO: Client side save error message
                return("");
            }
        }
Exemplo n.º 6
0
        public static string GetAnyDependentTasks(string id)
        {
            string result = "";

            // get the todo list items
            ToDoService.ToDoServiceClient client = new ToDoService.ToDoServiceClient();

            try
            {
                List <ToDoService.ToDoItemContract> toDoItems = client.GetToDoItems("").ToList();

                // get specific record
                ToDoService.ToDoItemContract singleRecord = toDoItems.Where(tdi => tdi.Id == id).FirstOrDefault();

                // get records the have the same parentid as the id passed in and order by orderid asc
                // only those whose orderid < than singleRecord.OrderId
                foreach (var item in toDoItems.Where(tdi => tdi.Complete == false && tdi.Id == singleRecord.ParentId && tdi.OrderId < singleRecord.OrderId).OrderBy(tdi => tdi.OrderId).ToList())
                {
                    result = string.Format("{0}<li>{1}</li>", result, item.Title);
                }

                // if result is not empty, add enclosing ul tag
                if (!string.IsNullOrWhiteSpace(result))
                {
                    result = string.Format("<ul>{0}</ul>", result);
                }

                client.Close();
            }
            catch (Exception ex)
            {
                // TODO: Log error
                client.Abort();
            }

            return(result);
        }
Exemplo n.º 7
0
        public static ToDoService.ToDoItemContract[] GetDependentTaskOptions(string id)
        {
            List <ToDoService.ToDoItemContract> matches = new List <ToDoService.ToDoItemContract>();

            // get the todo list items
            ToDoService.ToDoServiceClient client = new ToDoService.ToDoServiceClient();

            try
            {
                List <ToDoService.ToDoItemContract> toDoItems = client.GetToDoItems("").ToList();
                client.Close();
                // get specific record
                ToDoService.ToDoItemContract singleRecord = toDoItems.Where(tdi => tdi.Id == id).FirstOrDefault();
                // get all dependents with lower order ID not including current task
                matches = toDoItems.Where(tdi => tdi.Id != id && tdi.OrderId < singleRecord.OrderId).ToList();
            }
            catch (Exception ex)
            {
                // TODO: Log error
                client.Abort();
            }

            return(matches.ToArray());
        }