public IActionResult AddProduct(string product_name, IFormFile product_img, string product_category, string product_price, string filter, string product_discount, string product_info, string page) { ThucDon newProduct = new ThucDon(); if (product_img != null) { string path_to_image = "wwwroot/uploads/product/" + product_img.FileName; using (var stream = new FileStream(path_to_image, FileMode.Create)) { product_img.CopyTo(stream); } newProduct.HinhAnh = product_img.FileName; } newProduct.TenThucDon = product_name; newProduct.MaLoai = int.Parse(product_category); newProduct.Gia = float.Parse(product_price); newProduct.KhuyenMai = int.Parse(product_discount); newProduct.MoTa = product_info; ThucDonViewModel query = new ThucDonViewModel(db); query.InsertThucDon(newProduct); var response = query.GetDataWithCateByPage(filter, int.Parse(page)); return(Json(response)); }