public async Task <ActionResult> AddTodo(DTOTodo _todo) { if (ModelState.IsValid) { try { var todo = new Todos//create object todo { Title = _todo.Title, Description = _todo.Description, StartDate = _todo.Start, EndDate = _todo.End }; await todoContext.AddAsync(todo); //insert in database todoContext.SaveChanges(); AddUserTodo(); } catch (Exception ex) { throw ex; } } else { var message = string.Join(" | ", ModelState.Values .SelectMany(v => v.Errors) .Select(e => e.ErrorMessage)); _logger.LogError(LoggingEvents.MODEL_ERROR, message); } return(RedirectToAction("Index")); }
public ActionResult MarkTodoAsDone([Bind(include: "Title")] DTOTodo todo) { //var todo1 = new Todos() { IsDone = true }; try { using (todoContext) { todoContext.Database.ExecuteSqlCommand("uspMarkTodoAsDone @p0", parameters: new[] { todo.Title }); } } catch (Exception ex) { throw ex; } return(Json("Done !" + todo.Title)); }
public ActionResult DeleteTodo(DTOTodo t) { //return Json("I should remove a todo from database !" + t.Title); return(Ok("I should remove a todo from database !" + t.Title)); }