public bool addTodo(string username, Todo todo) { if (!userTodos.ContainsKey(username)) { userTodos[username] = new HashSet<Todo>(); } return userTodos[username].Add(todo); }
public bool editTodo(string username, Todo updated) { bool result = false; if (userTodos.ContainsKey(username)) { var todos = userTodos[username]; Todo modified = todos.Single(x => x.ID == updated.ID); todos.Remove(modified); todos.Add(updated); result = true; } return result; }
public AjaxContinuation EditTodoCommand(TodoEditModel input) { var todo = new Todo(input.ID) { Description = input.Description, Title = input.Title }; bool successful = todoService.editTodo(input.Username, todo); return new AjaxContinuation() { ShouldRefresh = false, Success = successful, Message = successful ? "Changes saved!" : "Changes not saved.." }; }
public AjaxContinuation AddTodoCommand(TodoAddModel input) { var todo = new Todo() { Description = input.Description, Title = input.Title }; bool successful = todoService.addTodo(input.Username, todo); return new AjaxContinuation() { ShouldRefresh = successful, Success = successful, Message = successful?"Todo added!":"Todo not added.." }; }