public IActionResult Post([FromBody] TypeProductMv typeProduct)
 {
     try
     {
         return(Created(Url.Action("Get"), _container.TypeProductFactory.CreateNew(typeProduct)));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(BadRequest());
     }
 }
 public IActionResult Put(Guid id, [FromBody] TypeProductMv typeProduct)
 {
     try
     {
         return(Ok(_container.TypeProductFactory.Update(id, typeProduct)));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(BadRequest());
     }
 }
        public IActionResult AddTypeProduct(TypeProductMv typeProduct)
        {
            var res = TypeProductBus.CreateNewTypeProductBusAsync(typeProduct).Result;

            if (res)
            {
                TempData[ConstKey.Success] = "Success";
            }
            else
            {
                TempData[ConstKey.Error] = "Fail, Try again!";
            }
            return(RedirectToAction("ForProduct", "TypeProduct", new { productId = typeProduct.ProductId }));
        }
Beispiel #4
0
        internal static async Task <bool> CreateNewTypeProductBusAsync(TypeProductMv typeProduct)
        {
            var res = await ServiceApi.PostData <TypeProductMv>(ModelName, typeProduct);

            return(res.StatusCode == HttpStatusCode.Created);
        }