public IActionResult Post([FromBody] Models.Sortimat.Sh1Assembly5202Datum item) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (item == null) { return(BadRequest()); } this.OnSh1Assembly5202DatumCreated(item); this.context.Sh1Assembly5202Data.Add(item); this.context.SaveChanges(); return(Created($"odata/Sortimat/Sh1Assembly5202Data/{item.id}", item)); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult PutSh1Assembly5202Datum(int key, [FromBody] Models.Sortimat.Sh1Assembly5202Datum newItem) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (newItem == null || (newItem.id != key)) { return(BadRequest()); } this.OnSh1Assembly5202DatumUpdated(newItem); this.context.Sh1Assembly5202Data.Update(newItem); this.context.SaveChanges(); var itemToReturn = this.context.Sh1Assembly5202Data.Where(i => i.id == key); return(new ObjectResult(SingleResult.Create(itemToReturn))); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
partial void OnSh1Assembly5202DatumUpdated(Models.Sortimat.Sh1Assembly5202Datum item);