Ejemplo n.º 1
0
 public void CreateProduct(ProductUpdateDtos products)
 {
     if (products == null)
     {
         throw new ArgumentNullException(nameof(products));
     }
     _context.Products.Add(products);
     SaveChanges();
 }
Ejemplo n.º 2
0
        public void UpdateProduct(int ProductID, ProductUpdateDtos products)
        {
            var updateProducts = GetProductByID(ProductID);

            if (updateProducts == null)
            {
                _logger.LogInformation("No Product available");
            }
            var updateProductText = "Update dbo.Products SET ProductName = @ProductName, ProductPrice = @ProductPrice, Active = @Active, ModifiedDate = @ModifiedDate, ModifiedBy = @ModifiedBy Where ProductID = @ProductIDParam";
            var ProductName       = new SqlParameter("@ProductName", products.ProductName);
            var ProductPrice      = new SqlParameter("@ProductPrice", products.ProductPrice);
            var Active            = new SqlParameter("@Active", products.Active);
            var ModifiedDate      = new SqlParameter("@ModifiedDate", DateTime.Now);
            var ModifiedBy        = new SqlParameter("@ModifiedBy", "Admin");
            var ProductIDParam    = new SqlParameter("@ProductIDParam", ProductID);
            int noOfRowUpdated    = _context.Database.ExecuteSqlCommand(updateProductText, ProductName, ProductPrice, Active, ModifiedDate, ModifiedBy, ProductIDParam);
        }
Ejemplo n.º 3
0
 public ActionResult <ProductUpdateDtos> UpdateProducts(int ProductID, ProductUpdateDtos productUpdateDtos)
 {
     _writeRepository.UpdateProduct(ProductID, productUpdateDtos);
     return(NoContent());
 }
Ejemplo n.º 4
0
        public ActionResult <Products> CreateProduct(ProductUpdateDtos productCreateDtos)
        {
            _writeRepository.CreateProduct(productCreateDtos);

            return(Ok());
        }