public async Task <IActionResult> PutProsumerConsumption([FromRoute] long id, [FromBody] ProsumerConsumption prosumerConsumption) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != prosumerConsumption.id) { return(BadRequest()); } _context.Entry(prosumerConsumption).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProsumerConsumptionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IHttpActionResult> PutProsumption(int id, Prosumption prosumption) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != prosumption.ProsumptionId) { return(BadRequest()); } db.Entry(prosumption).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProsumptionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> DeleteProsumer(string id) { Prosumer prosumer = await db.Prosumers.FindAsync(id); if (prosumer == null) { return(NotFound()); } Identity identity = await db.Identities.FindAsync(prosumer.IdentityId); if (identity == null) { return(NotFound()); } db.Identities.Remove(identity); db.Prosumers.Remove(prosumer); await db.SaveChangesAsync(); return(Ok(prosumer)); }