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

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

                this.OnStudentCreated(item);
                this.context.Students.Add(item);
                this.context.SaveChanges();

                var key = item.StudentID;

                var itemToReturn = this.context.Students.Where(i => i.StudentID == key);

                Request.QueryString = Request.QueryString.Add("$expand", "Gender,Class1");

                return(new ObjectResult(SingleResult.Create(itemToReturn))
                {
                    StatusCode = 201
                });
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Esempio n. 2
0
 partial void OnStudentUpdated(Models.ConDb.Student item);
Esempio n. 3
0
 partial void OnStudentDeleted(Models.ConDb.Student item);