public IHttpActionResult PutTasks(int id, Tasks task) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != task.Id) { return BadRequest(); } // altera a data da modificação task.Modified = DateTime.Now; db.Entry(task).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TasksExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IActionResult AddTask(TodoItem t) { if (ModelState.IsValid) { _db.TodoItem.Add(t); _db.SaveChanges(); } return(RedirectToAction("Index")); }
public IActionResult AddTask(Tasks taskToAdd) { if (ModelState.IsValid) { _context.Tasks.Add(taskToAdd); _context.SaveChanges(); return(RedirectToAction("TasksLists")); } return(View()); }
public ActionResult Create([Bind(Include = "ID,Subject,Descriptions,Date")] TaskList taskList) { if (ModelState.IsValid) { db.Tasks.Add(taskList); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(taskList)); }
public IActionResult CreateTask(TaskList task) { task.UserId = User.FindFirst(ClaimTypes.NameIdentifier).Value; if (ModelState.IsValid) { _context.TaskList.Add(task); _context.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("CreateTask")); } }
public IHttpActionResult PostUsers(Users user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // passa a hashzinha na senha user.Password = Helper.GetHash(user.Password); user.Username = user.Username.ToLower(); // ver primeiro se nao tem usuário registrado com o mesmo login if (UsersExists(user.Username)) { return(StatusCode(HttpStatusCode.Conflict)); } db.Users.Add(user); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = user.Id }, user)); }