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 ActionResult PostComment(String name, String phone, String content, String productId) { CommentDto comment = new CommentDto(); comment.Name = name; try { comment.ProductId = int.Parse(productId); } catch (Exception ex) { comment.ProductId = 0; } comment.Phone = phone; comment.Content = content; ProductHandler prodHandler = new ProductHandler(); prodHandler.AddComment(comment); return RedirectToAction("ProductDetail", "Home", new { productCode = productId }); }