public ActionResult AddProductRequest(String name, String code, String category, String price, String image, String desc) { ProductHandler prodHandler = new ProductHandler(); ProductDto product = new ProductDto(); product.Name = name; product.Code = code; product.CategoryId = int.Parse(category); product.Price = float.Parse(price); product.Image = image; product.Description = System.Net.WebUtility.HtmlDecode(desc); prodHandler.AddNewProduct(product); if (Session[CONST.SESSION.USER] != null) { UserDto userDto = (UserDto)Session[CONST.SESSION.USER]; if (UserHandler.AdminLogin(userDto.Username, userDto.Password) == CONST.ROLE.ADMIN) { return(RedirectToAction("Index", "Admin")); } else if (UserHandler.AdminLogin(userDto.Username, userDto.Password) == CONST.ROLE.MOD) { return(RedirectToAction("Index", "Mod")); } } return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult <ProductOut> > PostProduct([FromForm] ProductIn productIN) { try { if (productIN.ID == 0) { return(await m_Handler.AddNewProduct(productIN)); } return(await m_Handler.UpdateProduct(productIN)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw; } }