Пример #1
0
        public IActionResult PutRole(string key, [FromBody] Models.Crm.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();

                var itemToReturn = this.context.Roles.Where(i => i.Id == key);
                return(new ObjectResult(SingleResult.Create(itemToReturn)));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Пример #2
0
        public IActionResult Post([FromBody] Models.Crm.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/Crm/Roles/{item.Id}", item));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Пример #3
0
 partial void OnRoleUpdated(Models.Crm.Role item);
Пример #4
0
 partial void OnRoleDeleted(Models.Crm.Role item);
Пример #5
0
 partial void OnRoleCreated(Models.Crm.Role item);