Пример #1
0
        public IActionResult PutUser(string key, [FromBody] Models.Crm.User newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnUserUpdated(newItem);
                this.context.Users.Update(newItem);
                this.context.SaveChanges();

                var itemToReturn = this.context.Users.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.User item)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnUserCreated(item);
                this.context.Users.Add(item);
                this.context.SaveChanges();

                return(Created($"odata/Crm/Users/{item.Id}", item));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Пример #3
0
 partial void OnUserUpdated(Models.Crm.User item);
Пример #4
0
 partial void OnUserDeleted(Models.Crm.User item);
Пример #5
0
 partial void OnUserCreated(Models.Crm.User item);