Esempio n. 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));
            }
        }
Esempio n. 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));
            }
        }
Esempio n. 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));
            }
        }
Esempio n. 4
0
 partial void OnTaskStatusUpdated(Models.Crm.TaskStatus item);
Esempio n. 5
0
 partial void OnTaskStatusDeleted(Models.Crm.TaskStatus item);