public IHttpActionResult PutProsumer(int id, DAB4.Modeller.Prosumer prosumer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != prosumer.Id) { return(BadRequest()); } db.Entry(prosumer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProsumerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetProsumer(int id) { DAB4.Modeller.Prosumer prosumer = db.Prosumere.Find(id); if (prosumer == null) { return(NotFound()); } return(Ok(prosumer)); }
public IHttpActionResult PostProsumer(DAB4.Modeller.Prosumer prosumer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Prosumere.Add(prosumer); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = prosumer.Id }, prosumer)); }
public IHttpActionResult DeleteProsumer(int id) { DAB4.Modeller.Prosumer prosumer = db.Prosumere.Find(id); if (prosumer == null) { return(NotFound()); } db.Prosumere.Remove(prosumer); db.SaveChanges(); return(Ok(prosumer)); }