public IHttpActionResult PutTaskModel(int id, TaskModel taskModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != taskModel.TaskId) { return(BadRequest()); } db.Entry(taskModel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TaskModelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult <TaskDto> Create(TaskDto item) { item.Id = Guid.NewGuid().ToString(); _dbContext.TaskItems.Add(item); _dbContext.SaveChanges(); return(CreatedAtRoute("GetTaskById", new { id = item.Id }, item)); }
public bool DeleteTaks(TaskModel id) { dbContext.Tasks.Remove(id); return(dbContext.SaveChanges() == 0); }