Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 public bool DeleteTaks(TaskModel id)
 {
     dbContext.Tasks.Remove(id);
     return(dbContext.SaveChanges() == 0);
 }