public async Task WhenDeletingExistingProduct_ThenNoContentIsReturned()
        {
            ApiResponse <ViewProduct> createResponse = await _productApiClient.Create(ProductModels.GetCreateModel());

            ApiResponse <Response> deleteResponse = await _productApiClient.Delete(createResponse.Response.Id);

            Assert.That(deleteResponse.HttpStatusCode, Is.EqualTo(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
 public async Task TearDown()
 {
     if (_productIdToDelete != default(int))
     {
         await _productApiClient.Delete(_productIdToDelete);
     }
 }
Esempio n. 3
0
 public async Task TearDown()
 {
     if (_createdProductId != default(int))
     {
         await _productApiClient.Delete(_createdProductId);
     }
 }
Esempio n. 4
0
 public async Task<ApiResult<bool>> Delete(int id)
 {
     
     var result = await _productApiClient.Delete(id);
     if (result.IsSuccessed)
     {
         TempData["Result"] = result.Message;              
         
     }
     return result;
 }
Esempio n. 5
0
        public async Task <IActionResult> Delete(int id, string pageIndex)
        {
            var result = await _productApiClient.Delete(id);

            if (result == null)
            {
                TempData["error"] = result.Message;
                return(RedirectToAction("Index", new { pageIndex = !string.IsNullOrWhiteSpace(pageIndex) ? int.Parse(pageIndex) : 1 }));
            }
            else
            {
                TempData["result"] = "Xóa sản phẩm thành công";
                return(RedirectToAction("Index", new { pageIndex = !string.IsNullOrWhiteSpace(pageIndex) ? int.Parse(pageIndex) : 1 }));
            }
        }
Esempio n. 6
0
        public async Task <IActionResult> Delete(int id)
        {
            var result = await _productApiClient.Delete(id);

            if (result)
            {
                TempData["message"] = "Xóa sản phẩm thành công";
                return(RedirectToAction("List"));
            }
            else
            {
                TempData["message"] = "Xóa sản phẩm thất bại";
                return(RedirectToAction("List"));
            }
        }
Esempio n. 7
0
        public async Task <IActionResult> Delete(ProductDeleteRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var result = await _productApiClient.Delete(request.Id);

            if (result.IsSuccessed)
            {
                TempData["result"] = "Xóa sản phẩm thành công";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", result.Message);

            return(View(request));
        }
Esempio n. 8
0
        public async Task <IActionResult> Delete(ProductDeleteRequest request)  // lấy request từ thằng backeEnd thông qua thằng UserApiClient
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var result = await _productApiClient.Delete(request.Id);// với id lấy về trên kia trong request và thực hiện xóa

            if (result)
            {
                // khi thành công ta có thể tạo một TempData  đây là đầu đi và sẽ có đầu nhận dữ liệu này nhe bên View Của nó
                TempData["result"] = "Xóa Thành Công"; //có key là result
                return(RedirectToAction("Index"));     // nếu thành công thì chuyển tới phân trang là Index
            }

            return(View(request));//nếu ko thành công ta chả về request để xem request
        }
Esempio n. 9
0
        public async Task <IActionResult> Delete(int id)
        {
            await _productApiClient.Delete(id);

            return(RedirectToAction("Index"));
        }
Esempio n. 10
0
 public async Task TearDown()
 {
     await _productApiClient.Delete(_createdProductId);
 }
Esempio n. 11
0
        public async Task <ApiResult <bool> > Delete(int id)
        {
            var data = await _productApiClient.Delete(id);

            return(data);
        }