Beispiel #1
0
        public IActionResult PutTask(int key, [FromBody] Models.Crm.Task newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnTaskUpdated(newItem);
                this.context.Tasks.Update(newItem);
                this.context.SaveChanges();

                var itemToReturn = this.context.Tasks.Where(i => i.Id == key);

                Request.QueryString = Request.QueryString.Add("$expand", "Opportunity,TaskType,TaskStatus");

                return(new ObjectResult(SingleResult.Create(itemToReturn)));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Beispiel #2
0
        public IActionResult Post([FromBody] Models.Crm.Task item)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                this.OnTaskCreated(item);
                this.context.Tasks.Add(item);
                this.context.SaveChanges();

                var key          = item.Id;
                var itemToReturn = this.context.Tasks
                                   .Where(i => i.Id == key)
                                   .Include(i => i.Opportunity)
                                   .Include(i => i.TaskType)
                                   .Include(i => i.TaskStatus)
                                   .FirstOrDefault();

                return(new JsonResult(itemToReturn, new Newtonsoft.Json.JsonSerializerSettings
                {
                    ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore,
                    DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc
                })
                {
                    StatusCode = 201
                });
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Beispiel #3
0
 partial void OnTaskUpdated(Models.Crm.Task item);
Beispiel #4
0
 partial void OnTaskDeleted(Models.Crm.Task item);
Beispiel #5
0
 partial void OnTaskCreated(Models.Crm.Task item);