public IActionResult Post([FromBody] Models.DbSinDarEla.BaseAnreden item) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (item == null) { return(BadRequest()); } this.OnBaseAnredenCreated(item); this.context.BaseAnredens.Add(item); this.context.SaveChanges(); return(Created($"odata/DbSinDarEla/BaseAnredens/{item.AnredeID}", item)); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult PutBaseAnreden(int key, [FromBody] Models.DbSinDarEla.BaseAnreden newItem) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (newItem == null || (newItem.AnredeID != key)) { return(BadRequest()); } this.OnBaseAnredenUpdated(newItem); this.context.BaseAnredens.Update(newItem); this.context.SaveChanges(); var itemToReturn = this.context.BaseAnredens.Where(i => i.AnredeID == key); return(new ObjectResult(SingleResult.Create(itemToReturn))); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
partial void OnBaseAnredenUpdated(Models.DbSinDarEla.BaseAnreden item);