示例#1
0
        public async Task <IActionResult> Create([FromBody] CreateCustomTaskRequest smartTaskRequest)
        {
            var smartTask = new SmartTask
            {
                Title       = smartTaskRequest.Title,
                Description = smartTaskRequest.Description,
                Importance  = smartTaskRequest.Importance,
                DueDate     = smartTaskRequest.DueDate,
                IsCompleted = smartTaskRequest.IsCompleted,
                UserId      = HttpContext.GetUserId()
            };

            await _smartTaskService.CreateSmartTaskAsync(smartTask);

            var baseUrl     = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
            var locationUri = baseUrl + "/" + ApiRoutes.CustomTask.Get.Replace("smartTaskTitle", smartTask.Title);

            var response = new SmartTaskResponse
            {
                Title       = smartTask.Title,
                Description = smartTask.Description,
                Importance  = smartTask.Importance,
                DueDate     = smartTask.DueDate,
                IsCompleted = smartTask.IsCompleted
            };

            return(Created(locationUri, response));
        }
示例#2
0
        protected async Task <CustomTaskResponse> CreateCustomTaskAsync(CreateCustomTaskRequest request)
        {
            var response = await TestClient.PostAsJsonAsync(ApiRoutes.CustomTask.Create, request);

            return((await response.Content.ReadAsAsync <Response <CustomTaskResponse> >()).Data);
        }