Exemplo n.º 1
0
 public IActionResult AddProduct([FromBody] MvAddProduct product)
 {
     try
     {
         var added = _productService.AddProduct(product);
         if (!added)
         {
             return(BadRequest());
         }
         return(Ok());
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 2
0
        public bool AddProduct(MvAddProduct product)
        {
            var jsonNew = JsonConvert.SerializeObject(product);

            using (var conn = _dah.GetConnection())
            {
                using (var cmd = new SqlCommand("SpProductProductRateTsk", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@Json", SqlDbType.NChar).Value = jsonNew;
                    cmd.CommandTimeout = int.Parse(_commandTimeout);
                    int rows = cmd.ExecuteNonQuery();
                    if (rows > 0)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
        }
Exemplo n.º 3
0
 public IActionResult AddProduct([FromBody] MvAddProduct product)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     try
     {
         var added = _productService.AddProduct(product);
         if (!added)
         {
             return(BadRequest());
         }
         return(Ok());
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 4
0
        public bool AddProduct(MvAddProduct product)
        {
            using (var con = _da.GetConnection())
            {
                var jsonNew = JsonConvert.SerializeObject(product);
                var cmd     = con.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "SpProductInsTsk_OUTPUT";
                cmd.Parameters.Add("@Json", SqlDbType.NVarChar).Value = jsonNew;
                cmd.CommandTimeout = _commandTimeout;

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    return(true);
                }
                return(false);
            }
        }