public JsonResult Retrieve(DateTime month, StatementReportType type) { var provider = new StatementReportProvider(_dbContext); var model = provider.Retrieve(month, type); return(Json(model, JsonRequestBehavior.AllowGet)); }
public List <StatementReportViewModel> Retrieve(DateTime month, StatementReportType type) { var reportModel = new List <StatementReportViewModel>(); try { DateTime startDate = new DateTime(month.Year, month.Month, 1); DateTime endDate = new DateTime(month.Year, month.Month, DateTime.DaysInMonth(month.Year, month.Month)); SqlParameter[] sqlParams = new SqlParameter[3]; sqlParams[0] = new SqlParameter("@StartDate", SqlDbType.DateTime); sqlParams[0].Value = startDate; sqlParams[1] = new SqlParameter("@EndDate", SqlDbType.DateTime); sqlParams[1].Value = endDate; sqlParams[2] = new SqlParameter("@ReportType", SqlDbType.Int); sqlParams[2].Value = (int)type; reportModel = _context.Database.SqlQuery <StatementReportViewModel>("RetrieveStatementReport @StartDate, @EndDate, @ReportType", sqlParams).ToList(); return(reportModel); } catch (Exception ex) { throw; } }