public async void LoadItems() { var items = await _toDoItemDomainManager.GetByStatusAsync(ToDoItemStatus.InProgress); ToDoItems.Clear(); ToDoItems.AddRange(items); }
public void FindAllItems_FindsAll_ArraySizeOK() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Peter"; string familyName = "Jansson"; Person assignee = new Person(personId, firstName, familyName); int expectedSizeOfToDoItems = 3; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 3 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); todoItems.AddToDoItem(null, description3); //act ToDo[] itemArray = todoItems.FindAll(); //assert Assert.Equal(expectedSizeOfToDoItems, itemArray.Length); }
public ActionResult Update() { List <ToDoItems> allItems = ToDoItems.GetAll(); int itemId = int.Parse((Request.Query["id"])); return(View(allItems[itemId])); }
public void Remove_RemoveFirst_RemoveOnlyOne() { //arrange ToDo myToDo = null; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; int expectedNumberOfItems = 2; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 3 items int myInitialNumber = todoItems.Size(); myToDo = todoItems.AddToDoItem(null, description1); todoItems.AddToDoItem(null, description2); todoItems.AddToDoItem(null, description3); //act todoItems.Remove(myToDo); int myAdjustedNumber = todoItems.Size(); //assert Assert.Equal(description1, myToDo.Description); Assert.NotEqual(myInitialNumber, myAdjustedNumber); Assert.Equal(expectedNumberOfItems, myAdjustedNumber); }
private void AddToDoItem() { ToDoItems.Add(new ToDoItemViewModel { Text = "[Add text]" }); HasChanges = true; }
public void FindByAssigneePerson_NullPerson_ReturnsUnassignedItems() { //findbyAssignee(null) will return the unassigned items //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee1 = new Person(personId, firstName, familyName); personId = PersonSequencer.getNext(); Person assignee2 = new Person(personId, "Clara", familyName); Person assignee3 = null; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; //TodoSequencer.reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 3 items todoItems.AddToDoItem(assignee1, description1); todoItems.AddToDoItem(assignee2, description2); todoItems.AddToDoItem(assignee3, description3); //act ToDo[] foundItemsArray = todoItems.FindByAssignee(assignee3); //assert Assert.Single(foundItemsArray); }
public void FindUnassigned_FindOnlyOne_Arraysize1() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); personId = PersonSequencer.getNext(); Person assignee2 = new Person(personId, "Clara", familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 3 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee2, description2); todoItems.AddToDoItem(null, description3); //act ToDo[] foundItemsArray = todoItems.FindUnassignedTodoItems(); //assert Assert.Single(foundItemsArray); Assert.Equal(description3, foundItemsArray[0].Description); }
public void FindByDoneStatus_FindOnlyNotDone_Arraysize3() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 3 not done todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); todoItems.AddToDoItem(assignee, description3); //set one of the items to done. ToDo itemToBeDone = todoItems.FindById(1); itemToBeDone.Done = true; //act ToDo[] foundItemsArray = todoItems.FindByDoneStatus(false); //assert Assert.Equal(2, foundItemsArray.Length); }
public void FindByAssigneeInt_NotFound_Arraysize0() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 3 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); todoItems.AddToDoItem(null, description3); //act ToDo[] foundItemsArray = todoItems.FindByAssignee(personId + 10); //assert Assert.Empty(foundItemsArray); }
public void FindByDoneStatus_FindOnlyOne_Arraysize1() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 2 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); //set one item to done. ToDo itemToBeDone = todoItems.FindById(1); itemToBeDone.Done = true; //act ToDo[] foundItemsArray = todoItems.FindByDoneStatus(true); //assert Assert.Single(foundItemsArray); Assert.Equal(description1, foundItemsArray[0].Description); }
public void FindItemById_UnknownId_NoneReturned() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 2 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); int size = todoItems.Size(); //act ToDo foundItem = todoItems.FindById(size + 3); //assert Assert.Null(foundItem); }
public void FindItemById_FindOne_CorrectDescription() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 2 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); int size = todoItems.Size(); //act ToDo foundLastItem = todoItems.FindById(size); ToDo foundFirstItem = todoItems.FindById(1); //assert Assert.Equal(description2, foundLastItem.Description); Assert.Equal(description1, foundFirstItem.Description); }
public async Task <ActionResult <ToDoItems> > PostToDoItems(ToDoItems toDoItems) { _context.ToDoItems.Add(toDoItems); await _context.SaveChangesAsync(); return(CreatedAtAction("GetToDoItems", new { id = toDoItems.Atividade_Id }, toDoItems)); }
public void Remove_RemoveNull_NothingRemovedNoCrash() { //arrange ToDo myNullToDo = null; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; string description4 = "Do the home work."; int expectedNumberOfItems = 4; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 4 items todoItems.AddToDoItem(null, description1); todoItems.AddToDoItem(null, description2); todoItems.AddToDoItem(null, description3); todoItems.AddToDoItem(null, description4); //act todoItems.Remove(myNullToDo); int myAdjustedNumber = todoItems.Size(); //assert Assert.Equal(myAdjustedNumber, expectedNumberOfItems); }
private async void ChangeItemStatusAsync(object arg) { var selectedToDoItem = arg as ToDoItem; if (selectedToDoItem != null) { bool isOldStatusValueDone = ToDoItems.Where(x => x.Id == selectedToDoItem.Id).FirstOrDefault().IsDone; string statusNameForQuestion; if (isOldStatusValueDone) { statusNameForQuestion = AppResource.ActiveText; } else { statusNameForQuestion = AppResource.DoneText; } if (await UserDialogs.Instance.ConfirmAsync($"{AppResource.AreYouSureMarkItemText} {statusNameForQuestion}?", AppResource.ChangeStatusText, AppResource.YesText, AppResource.CancelText)) { bool isNewStatusValueDone = !isOldStatusValueDone; ToDoItems.Where(x => x.Id == selectedToDoItem.Id).FirstOrDefault().IsDone = isNewStatusValueDone; if (ToDoItems != null) { _dataService.SaveOrUpdateToDoItemsAsync(ToDoItems.ToList()); } } } }
public static void addToDoItem(ToDoItems t) { SqlConnection connection = FamilyDB.getConnection(); String query = "Insert into ListItems (familyID, listItem, listType, dueDate, isComplete) values (@familyID, @listItem, @listType, @dueDate, @isComplete)"; SqlCommand cmd = new SqlCommand(query, connection); cmd.Parameters.AddWithValue("@familyID", t.FamilyID); cmd.Parameters.AddWithValue("@listItem", t.ListItem); cmd.Parameters.AddWithValue("@listType", t.ListType); cmd.Parameters.AddWithValue("@dueDate", t.DueDate); cmd.Parameters.AddWithValue("@isComplete", t.IsComplete); try { if (connection != null) { connection.Open(); } cmd.ExecuteNonQuery(); } catch (SqlException ex) { Console.WriteLine(ex); } catch (Exception ex) { Console.WriteLine(ex); } finally { connection.Close(); } }
async Task ExecuteRefreshCommand() { if (IsBusy) { return; } IsBusy = true; try { var todos = await azureService.GetToDos(); ToDoItems.Clear(); foreach (var todo in todos) { ToDoItems.Add(todo); } } catch (Exception ex) { Acr.UserDialogs.UserDialogs.Instance.ShowError(ex.Message); } finally { IsBusy = false; } }
private async Task DeleteToDoItemAsync(ToDoItemViewModel toDoItemViewModel) { if (await _pageService.DisplayAlertAsync("Delete", $"Are you sure you want to delete {toDoItemViewModel.Name}?", "Yes", "No")) { ToDoItems.Remove(toDoItemViewModel); await _toDoService.DeleteToDoItemAsync(toDoItemViewModel.Key); } }
private async void OnDeleteItem(ToDoItem item) { if (item != null) { ToDoItems.Remove(item); await _toDoItemsRepository.DeleteItemAsync(item); } }
public void AddValue(string value) { if (string.IsNullOrWhiteSpace(value)) { return; } ToDoItems.Add(value); }
public IActionResult Add(ToDoItems t, string name) { TaskDB taskDB = new TaskDB(@"Data Source=.\sqlexpress;Initial Catalog=ToDo;Integrated Security=True;"); Category cat = taskDB.GetCategoryId(name); taskDB.AddToDo(t, cat); return(Redirect("/home/home")); }
public void UpdateItem(ToDoItemViewModel toDo) { var temp = ToDoItems.FirstOrDefault(a => a.item.UserId == toDo.UserId); ToDoItems.Add(new ToDoToServer { item = temp.item, MessageType = MessageType.UpDate }); JSONWorker.Add(ToDoItems); }
public async Task <ActionResult <ToDoItems> > AddToDoItems(ToDoItems item, DateTime date) { item.toBeCompletedBy = date; _context.TodoItems.Add(item); await _context.SaveChangesAsync(); // return CreatedAtAction(nameof(GetTodoItem), new { id = item.Id }, item); return(item); }
public async Task InitializeToDoItems() { IsRefreshing = true; List <ToDoItemViewModel> items = (await App.Repository.GetAllAsync()).ToViewModels().ToList(); ToDoItems.Clear(); ToDoItems = ToDoItems.AddRange(items); IsRefreshing = false; }
public IActionResult Update(ToDoItems item) { if (ModelState.IsValid) { _context.ToDoItems.Update(item); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(item)); }
public void Add(string text) { ToDoItems.Add(new ToDoItem() { Id = mTopId, Content = new StringReactiveProperty(text), Completed = new BoolReactiveProperty(false) }); mTopId++; }
public IActionResult Create([FromBody] ToDoItems item) { if (item == null) { NotFound(); } _toDoDbContext.todoItemes.Add(item); _toDoDbContext.SaveChanges(); return(CreatedAtRoute("GoTodo", new { id = item.Id }, item)); }
/// <summary> /// Get All Data /// </summary> /// <param name="request"></param> /// <param name="context"></param> /// <returns></returns> public override Task <ToDoItems> GetToDo(Empty request, ServerCallContext context) { ToDoItems objItems = new ToDoItems(); foreach (var item in _dataContext.ToDoDbItems) { objItems.ToDoItemList.Add(item); } return(Task.FromResult(objItems)); }
private async Task AddToDoItemAsync() { var viewModel = new ToDoItemDetailViewModel(new ToDoItemViewModel(), _toDoService, _pageService); viewModel.ToDoItemAdded += (source, item) => { ToDoItems.Add(new ToDoItemViewModel(item)); }; await _pageService.PushAsync(new ToDoItemDetailPage(viewModel)); }
public ActionResult UpdateSubmit() { List <ToDoItems> allItems = ToDoItems.GetAll(); int itemId = int.Parse((Request.Form["id"])); allItems[itemId].SetTitle(Request.Form["title"]); allItems[itemId].SetDescription(Request.Form["description"]); allItems[itemId].SetDueDate(Request.Form["due-date"]); allItems[itemId].SetImportance(Request.Form["importance"]); return(View("Index", allItems)); }