public IHttpActionResult PostAnteloD(AnteloD anteloD) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AnteloDs.Add(anteloD); try { db.SaveChanges(); } catch (DbUpdateException) { if (AnteloDExists(anteloD.Name)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = anteloD.Name }, anteloD)); }
public IHttpActionResult PutAnteloD(string id, AnteloD anteloD) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != anteloD.Name) { return(BadRequest()); } db.Entry(anteloD).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AnteloDExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetAnteloD(string id) { AnteloD anteloD = db.AnteloDs.Find(id); if (anteloD == null) { return(NotFound()); } return(Ok(anteloD)); }
public IHttpActionResult DeleteAnteloD(string id) { AnteloD anteloD = db.AnteloDs.Find(id); if (anteloD == null) { return(NotFound()); } db.AnteloDs.Remove(anteloD); db.SaveChanges(); return(Ok(anteloD)); }