コード例 #1
0
        public async Task <ApiResult <bool> > Update(ReviewUpdateRequest request, int reviewId)
        {
            var comment = await _context.ReViews.FindAsync(reviewId);

            comment.Content    = request.Content;
            comment.Created_At = DateTime.Now;
            return(await SaveChangeService.SaveChangeAsyncNotImage(_context));
        }
コード例 #2
0
        public async Task <IActionResult> Update(ReviewUpdateRequest request, int reviewId)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }
            var result = await _reviewService.Update(request, reviewId);

            if (result.IsSuccessed == false)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
コード例 #3
0
        public async Task <ApiResult <string> > Update(ReviewUpdateRequest request, int reviewId)
        {
            var json        = JsonConvert.SerializeObject(request);
            var httpContent = new StringContent(json, Encoding.UTF8, "application/json");
            var response    = await _client.PatchAsync($"/api/reviews/{reviewId}", httpContent);

            var result = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <ApiResultSuccess <string> >(result));
            }
            return(JsonConvert.DeserializeObject <ApiResultErrors <string> >(result));
        }