public ActionResult Add(NewTodo todo) { if (!this.ModelState.IsValid) { return(View(todo)); } _todoService.Add(todo.Name); return(RedirectToAction("Index")); }
public Todo NewTodo(NewTodo model) { DynamicParameters p = new DynamicParameters(); p.Add("@BoardId", model.boardid); p.Add("@Name", model.TodoName); Todo newtodo = SqlMapper.Query <Todo>(con, "NewTodo", param: p, commandType: CommandType.StoredProcedure).First(); return(newtodo); }
public ActionResult Create(NewTodo model) { if(!ModelState.IsValid) { return View("New", model); } Todo todo = new Todo {Item = model.Entry, Title = model.Title, Posted = DateTime.Now, State = 1}; _repository.Create(todo); return RedirectToAction("Index"); }
public ActionResult Update(NewTodo model) { if (!ModelState.IsValid) { return View("Edit", model); } Todo todo = _repository.GetTodo(model.Id); todo.Title = model.Title; todo.Item = model.Entry; _repository.Update(todo); return RedirectToAction("Index"); }
public Todo Post(NewTodo newTodo) { var todo = new Todo { Text = newTodo.Text, IsCompleted = false, CreatedAt = DateTime.Now }; _context.Todos.Add(todo); _context.SaveChanges(); return(todo); }
public ActionResult Index(string category, string id) { NewTodo oTodo = new NewTodo(); oTodo.TodoItems = DBHandler.getAllTodoItemsByCategoryId(id); oTodo.Categories = DBHandler.getAllCategories(); oTodo.TodoDTO = new TodoItemDTO(); ViewData.Model = oTodo; ViewBag.Category = category; return(View()); }
public IActionResult Delete([FromBody] NewTodoModel model) // delete Todo by id { var token = HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", string.Empty); if (_userService.Validate(token) != null) { NewTodo ret = _newTodoRepository.GetTodo(model.ID); if (ret != null) { try { _newTodoRepository.Delete(ret); _newTodoRepository.Save(); IEnumerable <NewTodo> todoList = _newTodoRepository.GetAllTodosById(model.NewCategoryId); var todos = _mapper.Map <IEnumerable <NewTodo> >(todoList); return(Ok(new { todos })); } catch (Exception ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } } else { return(BadRequest(new { message = "Item Not Found" })); } } else { return(Unauthorized(new { message = "Invalid Token" })); } }
public Todo NewToDo([FromBody] NewTodo model) { return(this.ser.NewTodo(model)); }
public void Delete(NewTodo todo) { _context.NewTodos.Remove(todo); }
public void Edit(NewTodo todo) { _context.NewTodos.Update(todo); }
public void AddTodo(NewTodo todo) { _context.NewTodos.Add(todo); }
public Todo NewTodo(NewTodo model) { return(this.repo.NewTodo(model)); }
public ActionResult New() { NewTodo model = new NewTodo(); return View(model); }
public ActionResult Edit(int id) { Todo entity = _repository.GetTodo(id); NewTodo model = new NewTodo {Entry = entity.Item, Title = entity.Title, Id = id}; return View(model); }