コード例 #1
0
        public IActionResult Post([FromBody] TaskAPI item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            Task task = TaskAPI.To(item);

            try
            {
                task = new TaskBF(DB).Create(task);

                return(CreatedAtRoute(
                           "TaskRoute",
                           new
                {
                    controller = "Task",
                    id = task.ID
                },
                           TaskAPI.From(task)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
コード例 #2
0
        public IActionResult Put(long id, [FromBody] TaskAPI item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            try
            {
                Task updateItem = new TaskBF(DB).Update(TaskAPI.To(item));

                return(new ObjectResult(TaskAPI.From(updateItem)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }