public IActionResult Post([FromBody] Models.Sortimat.Date item) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (item == null) { return(BadRequest()); } this.OnDateCreated(item); this.context.Dates.Add(item); this.context.SaveChanges(); return(Created($"odata/Sortimat/Dates/{item.Date1}", item)); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult PutDate(DateTime key, [FromBody] Models.Sortimat.Date newItem) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (newItem == null || (newItem.Date1 != key)) { return(BadRequest()); } this.OnDateUpdated(newItem); this.context.Dates.Update(newItem); this.context.SaveChanges(); var itemToReturn = this.context.Dates.Where(i => i.Date1 == key); return(new ObjectResult(SingleResult.Create(itemToReturn))); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
partial void OnDateUpdated(Models.Sortimat.Date item);
partial void OnDateDeleted(Models.Sortimat.Date item);