public IActionResult Post([FromBody] ProductModel newProduct)
 {
     try
     {
         productService.AddNewProduct(newProduct);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(ThrowInternalErrorServer(ex));
     }
 }
Пример #2
0
        public IActionResult Post([FromBody] ProductBasicInfoDTO newProduct)
        {
            int id;

            try
            {
                using (NorthwindContext dbContext = new())
                {
                    id = ProductSC.AddNewProduct(dbContext, newProduct);
                }

                return(Ok("Registered Id: " + id));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
 public static void AddProduct(string productName, int?supplierId, int?categoryId, decimal?unitPrice, short?unitsInStock, short?unitsOnOrder, short?reorderLevel, bool discontinued = false, string quantityPerUnit = "")
 {
     productService.AddNewProduct(productName, supplierId, categoryId, unitPrice, unitsInStock, unitsOnOrder, reorderLevel, discontinued, quantityPerUnit);
 }
 public static void Excercise5()
 {
     productService.AddNewProduct("Juzzy de uva Bonafont", 15.50m);
 }