public IHttpActionResult PostDashboardData(DashboardData dashboardData) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.DashboardData.Add(dashboardData); try { db.SaveChanges(); } catch (DbUpdateException) { if (DashboardDataExists(dashboardData.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = dashboardData.Id }, dashboardData); }
public IHttpActionResult PutDashboardData(string id, DashboardData dashboardData) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != dashboardData.Id) { return BadRequest(); } db.Entry(dashboardData).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DashboardDataExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }