예제 #1
0
 bool ValidateProduct(MODELS.Product product)
 {
     if (string.IsNullOrWhiteSpace(product.Name) || string.IsNullOrWhiteSpace(product.Description) ||
         product.Price <= 0)
     {
         return(false);
     }
     return(true);
 }
예제 #2
0
        public void TestAddProductSuccess()
        {
            var product = new MODELS.Product {
                Id = 0, Name = "GoPro", Description = "Camera", Price = 35000.00, Count = 5
            };

            MockRepository.GenerateMock <IProduct>().Expect(x => x.AddProduct(new MODELS.Product())).Return(1);
            var result = _productbdl.AddProduct(product);

            Assert.True(result > 0);
        }
예제 #3
0
        public IActionResult DeleteProduct(MODELS.Product product)
        {
            var success = _bdlProduct.DeleteProduct(product);

            if (success == 1)
            {
                return(StatusCode((int)HttpStatusCode.Created, 1));
            }
            else
            {
                return(StatusCode((int)HttpStatusCode.BadRequest));
            }
        }
예제 #4
0
 int IProduct.UpdateProduct(MODELS.Product product)
 {
     try
     {
         if (ValidateProduct(product))
         {
             return(_productRepository.UpdateProduct(product));
         }
         else
         {
             return(0);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
예제 #5
0
 int IProduct.DeleteProduct(MODELS.Product product)
 {
     return(_productRepository.DeleteProduct(product));
 }