Exemple #1
0
        public IActionResult Post([FromBody] Models.Sortimat.Sh2Assembly5308Datum item)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (item == null)
                {
                    return(BadRequest());
                }

                this.OnSh2Assembly5308DatumCreated(item);
                this.context.Sh2Assembly5308Data.Add(item);
                this.context.SaveChanges();

                return(Created($"odata/Sortimat/Sh2Assembly5308Data/{item.id}", item));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Exemple #2
0
        public IActionResult PutSh2Assembly5308Datum(int key, [FromBody] Models.Sortimat.Sh2Assembly5308Datum newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (newItem == null || (newItem.id != key))
                {
                    return(BadRequest());
                }

                this.OnSh2Assembly5308DatumUpdated(newItem);
                this.context.Sh2Assembly5308Data.Update(newItem);
                this.context.SaveChanges();

                var itemToReturn = this.context.Sh2Assembly5308Data.Where(i => i.id == key);
                return(new ObjectResult(SingleResult.Create(itemToReturn)));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Exemple #3
0
 partial void OnSh2Assembly5308DatumUpdated(Models.Sortimat.Sh2Assembly5308Datum item);