Hellow Team,
In my dataTable I want to select the data between date rage that will as well display product quantity and total amount at the footer.
public ActionResult GetTopTenBestSellingProducts()
{
ASPNETMASTERPOSTEntities db = new ASPNETMASTERPOSTEntities();
var dataList = db.tblSales.Join(
db.tblSalesDetails,
sales => sales.SalesId,
detail => detail.SalesId,
(sales, detail) => new { Sales = sales, detail = detail });
var modifiedData = dataList.GroupBy(x => new { x.Sales.OrderDate, x.detail.ProductId }).Select(x => new BestSellingProducts
{
SalesDetailId = x.FirstOrDefault().detail.SalesDetailId,
Quantity = x.Sum(s => s.detail.Quantity),
ProductId = x.Key.ProductId,
ProductName = x.FirstOrDefault().detail.tblProduct.ProductName,
SalesId = x.FirstOrDefault().Sales.SalesId,
strOrderDate = x.Key.OrderDate,
TotalAmount = x.Sum(s => s.Sales.TotalAmount)
}).Take(10).ToList();
return Json(responseData, JsonRequestBehavior.AllowGet);
}
Vishal JoshiPosted Jul 12, 2023, 11:18 AM
Hello Emma,
You need to pass from and to date as a input parameter and add filter on dataset for the dates. please check the below code for the same.
Thanks
Vishal Joshi
Emmmanuel FIADUFEPosted Jul 12, 2023, 9:48 PM
Thank you team, it's working now
Amit MohantyPosted Jul 11, 2023, 6:00 AM
Jignesh KumarPosted Jul 11, 2023, 3:16 AM
Hello,
You can use where clause to filter records,
You can call above methos passing start date and End date.
Lokesh VarmanPosted Jul 10, 2023, 5:02 PM
To select data between a date range and display product quantity and total amount at the footer, you can modify your existing code as follows: