Esempio n. 1
0
        public IHttpActionResult PutTask(int id, Task task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != task.Id)
            {
                return(BadRequest());
            }

            db.Entry(task).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!db.TaskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public IHttpActionResult PostSeverityTask(Task task, SeverityTask severityTask)
        {
            if (!ModelState.IsValid || task.Id != severityTask.TaskId || db.TaskExists(task.Id))
            {
                return(BadRequest(ModelState));
            }

            db.Tasks.Add(task);
            db.SeverityTasks.Add(severityTask);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = severityTask.TaskId }, severityTask));
        }