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

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

                this.OnClass1Created(item);
                this.context.Class1s.Add(item);
                this.context.SaveChanges();

                return(Created($"odata/ConDb/Class1s/{item.ClassID}", item));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Exemple #2
0
        public IActionResult PutClass1(int key, [FromBody] Models.ConDb.Class1 newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnClass1Updated(newItem);
                this.context.Class1s.Update(newItem);
                this.context.SaveChanges();

                var itemToReturn = this.context.Class1s.Where(i => i.ClassID == key);
                return(new ObjectResult(SingleResult.Create(itemToReturn)));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Exemple #3
0
 partial void OnClass1Updated(Models.ConDb.Class1 item);
Exemple #4
0
 partial void OnClass1Deleted(Models.ConDb.Class1 item);