public PartialViewResult WeReportPartialView(DateTime?fromDate, DateTime?toDate) { var ctx = new SmsContext(); if (fromDate == null) { fromDate = SystemConstant.MIN_DATE; } if (toDate == null) { toDate = SystemConstant.MAX_DATE; } var FromDateParam = new SqlParameter { ParameterName = "START_TIME", Value = Convert.ToDateTime(fromDate) }; var ToDateParam = new SqlParameter { ParameterName = "END_TIME", Value = Convert.ToDateTime(toDate) }; var tonkho = ctx.Database.SqlQuery <ReportWeek>("exec SP_REPORT_BY_WEEK @START_TIME, @END_TIME", FromDateParam, ToDateParam).Take(SystemConstant.MAX_ROWS).ToList <ReportWeek>(); ReportWeekModel model = new ReportWeekModel(); model.TheList = tonkho; ctx.Dispose(); return(PartialView("WeReportPartialView", model)); }
public ActionResult WeeklyReport() { var ctx = new SmsContext(); var tonkho = ctx.Database.SqlQuery <ReportWeek>("exec SP_GET_STATISTICS_BY_WEEK_OF_YEAR").Take(SystemConstant.MAX_ROWS).ToList <ReportWeek>(); var total = ctx.Database.SqlQuery <Report>("exec SP_GET_STATISTICS_OF_YEAR").Take(SystemConstant.MAX_ROWS).FirstOrDefault(); ReportWeekModel model = new ReportWeekModel(); model.TheList = tonkho; model.Total = total; ctx.Dispose(); return(View(model)); }