Esempio n. 1
0
        public IActionResult PutGender(int key, [FromBody] Models.ConData.Gender newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnGenderUpdated(newItem);
                this.context.Genders.Update(newItem);
                this.context.SaveChanges();

                var itemToReturn = this.context.Genders.Where(i => i.GenderID == key);
                this.OnAfterGenderUpdated(newItem);
                return(new ObjectResult(SingleResult.Create(itemToReturn)));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Esempio n. 2
0
        public IActionResult Post([FromBody] Models.ConData.Gender item)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnGenderCreated(item);
                this.context.Genders.Add(item);
                this.context.SaveChanges();

                return(Created($"odata/ConData/Genders/{item.GenderID}", item));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Esempio n. 3
0
 partial void OnAfterGenderUpdated(Models.ConData.Gender item);
Esempio n. 4
0
 partial void OnAfterGenderDeleted(Models.ConData.Gender item);
Esempio n. 5
0
 partial void OnGenderCreated(Models.ConData.Gender item);