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

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

                this.OnFm2Assembly5306DatumCreated(item);
                this.context.Fm2Assembly5306Data.Add(item);
                this.context.SaveChanges();

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

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

                this.OnFm2Assembly5306DatumUpdated(newItem);
                this.context.Fm2Assembly5306Data.Update(newItem);
                this.context.SaveChanges();

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