Exemplo n.º 1
0
        public IActionResult Post([FromBody] Models.Sortimat.Fm1Assembly5201Datum item)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnFm1Assembly5201DatumCreated(item);
                this.context.Fm1Assembly5201Data.Add(item);
                this.context.SaveChanges();

                return(Created($"odata/Sortimat/Fm1Assembly5201Data/{item.id}", item));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Exemplo n.º 2
0
        public IActionResult PutFm1Assembly5201Datum(int key, [FromBody] Models.Sortimat.Fm1Assembly5201Datum newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnFm1Assembly5201DatumUpdated(newItem);
                this.context.Fm1Assembly5201Data.Update(newItem);
                this.context.SaveChanges();

                var itemToReturn = this.context.Fm1Assembly5201Data.Where(i => i.id == key);
                return(new ObjectResult(SingleResult.Create(itemToReturn)));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Exemplo n.º 3
0
 partial void OnFm1Assembly5201DatumUpdated(Models.Sortimat.Fm1Assembly5201Datum item);