示例#1
0
        public IActionResult PutRole(int key, [FromBody] Models.CustomSecurity.Role newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnRoleUpdated(newItem);
                this.context.Roles.Update(newItem);
                this.context.SaveChanges();

                return(new NoContentResult());
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
示例#2
0
        public IActionResult Post([FromBody] Models.CustomSecurity.Role item)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnRoleCreated(item);
                this.context.Roles.Add(item);
                this.context.SaveChanges();

                return(Created($"odata/CustomSecurity/Roles/{item.Id}", item));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
示例#3
0
 partial void OnRoleUpdated(Models.CustomSecurity.Role item);
示例#4
0
 partial void OnRoleDeleted(Models.CustomSecurity.Role item);