private void PopulateCategories() { List <string> categories = ToDoItemData.GetCategories(); Category.DataSource = categories; Category.DataBind(); }
protected void Submit_Click(object sender, EventArgs e) { if (Page.IsValid) { ToDoItemData.AddItem(Description.Text, Category.SelectedValue); Description.Text = string.Empty; } }
public static ToDoItemViewModel ToItemViewModel(this ToDoItemData data) { return(new ToDoItemViewModel { Name = data.Name, IsCompleted = data.IsCompleted, UserId = data.UserId, ToDoId = data.ToDoId }); }
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; } }
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()); } }
/// <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; } }
public void UpdateItem(ToDoItemData item) { httpClient.PutAsJsonAsync(serviceApiUrl + UpdateUrl, item) .Result.EnsureSuccessStatusCode(); }