Exemplo n.º 1
0
        private void PopulateCategories()
        {
            List <string> categories = ToDoItemData.GetCategories();

            Category.DataSource = categories;
            Category.DataBind();
        }
Exemplo n.º 2
0
 protected void Submit_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         ToDoItemData.AddItem(Description.Text, Category.SelectedValue);
         Description.Text = string.Empty;
     }
 }
Exemplo n.º 3
0
 public static ToDoItemViewModel ToItemViewModel(this ToDoItemData data)
 {
     return(new ToDoItemViewModel
     {
         Name = data.Name,
         IsCompleted = data.IsCompleted,
         UserId = data.UserId,
         ToDoId = data.ToDoId
     });
 }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         // Bind Categories list to CategoriesDropDown and set the initial selected value
         List <string> categoriesList = ToDoItemData.GetCategories();
         categoriesList.Add("ALL");
         CategoryDropDown.DataSource = categoriesList;
         CategoryDropDown.DataBind();
         int currentCategoryIndex = categoriesList.IndexOf(CategoryFilter);
         CategoryDropDown.SelectedIndex = currentCategoryIndex;
     }
 }
Exemplo n.º 5
0
 protected void Submit_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(TODODescription.Text))
     {
         ErrorMessage.Visible = false;
         ToDoItemData.AddItem(TODODescription.Text, int.Parse(TODOPriority.SelectedValue));
         ResetForm();
     }
     else
     {
         ErrorMessage.Visible = true;
     }
 }
 public List <ToDoItem> PopulateList(int exception)
 {
     if (exception > 0)
     {
         List <ToDoItem> exceptionList = new List <ToDoItem>();
         foreach (var item in ToDoItemData.GetToDoItems())
         {
             if (item.Priority == exception)
             {
                 exceptionList.Add(item);
             }
         }
         return(exceptionList);
     }
     else
     {
         return(ToDoItemData.GetToDoItems());
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the list of ToDoItems from the data store and applies the
        /// category filter as well as the correct pagination.
        /// </summary>
        private void PruneList()
        {
            ListToDisplay = ToDoItemData.GetToDoItems();

            if (!string.IsNullOrWhiteSpace(CategoryFilter))
            {
                ListToDisplay = ListToDisplay.FindAll(HasCategory);
            }

            int endIndex = NumberOfRecordsToDisplay + CurrentIndex;

            if (endIndex > ListToDisplay.Count)
            {
                ListToDisplay = ListToDisplay.GetRange(CurrentIndex, ListToDisplay.Count - CurrentIndex);
                EnableNext    = false;
            }
            else
            {
                ListToDisplay = ListToDisplay.GetRange(CurrentIndex, NumberOfRecordsToDisplay);
                EnableNext    = true;
            }
        }
Exemplo n.º 8
0
 public void UpdateItem(ToDoItemData item)
 {
     httpClient.PutAsJsonAsync(serviceApiUrl + UpdateUrl, item)
     .Result.EnsureSuccessStatusCode();
 }