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

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

                this.OnTaskStatusUpdated(newItem);
                this.context.TaskStatuses.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.Crm.TaskStatus item)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnTaskStatusCreated(item);
                this.context.TaskStatuses.Add(item);
                this.context.SaveChanges();

                return(Created($"odata/Crm/TaskStatuses/{item.Id}", item));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
示例#3
0
        public IActionResult PutTaskStatus(int?key, [FromBody] Models.Crm.TaskStatus newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnTaskStatusUpdated(newItem);
                this.context.TaskStatuses.Update(newItem);
                this.context.SaveChanges();

                var itemToReturn = this.context.TaskStatuses.Where(i => i.Id == key);
                return(new ObjectResult(SingleResult.Create(itemToReturn)));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
示例#4
0
 partial void OnTaskStatusUpdated(Models.Crm.TaskStatus item);
示例#5
0
 partial void OnTaskStatusDeleted(Models.Crm.TaskStatus item);