Hello team,
In my bootstrap MVC application am using SB Admin template with Json, ajax and angularJS.
I have the following page.
1. Products stockIn page
2. Sales page.
And my question how do I display daily Sales, products quantity in stock, critical stocks and also plot it on a graph in admin dashboard.
Thank you all for your help.

Emmmanuel FIADUFERank #947 · 2.2K reputationPosted Apr 4, 2023, 12:11 PM EDT
Please do I need to create a new table like as you statated in your example because I have table like stockIn, Sales table and sales details table
Emmmanuel FIADUFERank #947 · 2.2K reputationPosted Apr 4, 2023, 12:57 PM EDT
Hello Sachin
I tried your code and did some changes to suit my code but is giving me some errors in the PlotGraph code
Sachin SinghRank #66 · 26.2K reputationPosted Apr 4, 2023, 5:24 AM EDT
create a viewModel
public class GraphModel { public DailySales dailySales {get;set;} public Stockdaily stock{get;set;} public CriticalStock criticalStock{get;set;} } public class DailySales { public DateTime date {get;set;} public decimal SaleAmount{get;set;} } public class Stock { public string ProductName{get;set;} public int Qty{get;set;} } public class CriticalStock { public string ProductName{get;set;} public int Qty{get;set;} }now fill the above view model
public class GraphModel { public List dailySales {get;set;} public List stocks{get;set;} public List criticalStocks{get;set;} } public ActionResult PlotGraph() { GraphModel model= new GraphModel(); YourDbContext db= new YourDbContext(); var res1=db.Sales.Group(x=>x.SellDate).select(x=>new DailySales(){ date=x.Key, SaleAmount= Sum(x.Amount) }).ToList(); var res2=db.Products.select(x=>new Stock(){ ProductName=x.ProductName, Qty= x.Qty }).ToList(); var res3=db.Products.Where(x=>x.Quantity1000).select(x=>new Stock(){ ProductName=x.ProductName, Qty= x.Qty }).ToList(); model.dailySales =res1; model.stocks=res2; model.criticalStocks=res3; return Json(model,JsonRequestBehaviour.AllowGet) }Now based on json response use ChartJs library and assign x and y axes.
Pasang TamangRank #449 · 5.6K reputationPosted Apr 3, 2023, 5:32 AM EDT
Hi,
Please check this code repository https://github.com/go2ismail/Asp.Net-User-Role-Membership-Example. This will gives you idea about creating admin dashboard. For graph you can check this article https://www.c-sharpcorner.com/article/creating-charts-with-asp-net-core-mvc-using-google-chart-api-part-two/. I hope you will find these helpful.
Regards,
Pasang
Emmmanuel FIADUFERank #947 · 2.2K reputationPosted Apr 3, 2023, 11:54 AM EDT
Thank you Tamang, I will check it and revert