public async Task <IActionResult> GenerateSalesAnalysis(SALESANALYSISFILTER filter) { if (filter != null) { if (filter.CompanyCode != "404") { var model = await qneReportService.GenerateSalesAnalysis(filter); if (model != null) { return(Ok(model)); } else { return(BadRequest()); } } } return(BadRequest()); }
public async Task <IEnumerable <SALESANALYSISRESULT> > GenerateSalesAnalysis(SALESANALYSISFILTER filter) { using (IDbConnection con = new SqlConnection(QNEConnectionString.ChooseConnection(filter.CompanyCode))) { string sql = "select * from dbo.FN_SalesAnalysis(@DateFrom,@DateTo,@IncludeGST,@IncludeDN,@includeCN,@includeCS,@stockControlOnly)"; var fromDate = filter.DateFrom == null?Convert.ToDateTime("1900-01-01") : filter.DateFrom; var toDate = filter.DateTo == null ? DateTime.Now : filter.DateTo; var p = new DynamicParameters(); p.Add("@DateFrom", fromDate); p.Add("@DateTo", toDate); p.Add("@IncludeGST", filter.IncludeGST); p.Add("@IncludeDN", filter.IncludeDN); p.Add("@includeCN", filter.includeCN); p.Add("@includeCS", filter.includeCS); p.Add("@stockControlOnly", filter.stockControlOnly); var res = await con.QueryAsync <SALESANALYSISRESULT>(sql, p); return(res); } }