public IHttpActionResult PostCalcRelease(CalcRelease calcRelease) { if (!ModelState.IsValid) { return BadRequest(ModelState); } calcRelease.CalcID = calcRelease.ID; calcRelease.Configuration = Convert.ToString(calcRelease.Configuration); calcRelease.User = HttpContext.Current.User.Identity.Name.ToString(); calcRelease.UpdateDate = DateTime.Now; db.CalcRelease.Add(calcRelease); db.SaveChanges(); return Ok(calcRelease); }
public IHttpActionResult PutCalcRelease(int id, CalcRelease calcRelease) { if (!ModelState.IsValid) { return BadRequest(ModelState); } CalcRelease CalcReleaseFind = db.CalcRelease.FirstOrDefault(i => i.CalcID == id); CalcReleaseFind.User = HttpContext.Current.User.Identity.Name.ToString(); CalcReleaseFind.UpdateDate = DateTime.Now; CalcReleaseFind.Configuration = calcRelease.Configuration; CalcReleaseFind.Version = calcRelease.Version; db.Entry(CalcReleaseFind).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CalcReleaseExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }