public async Task <ActionResult> Index(CompanyPerformanceSM sm) { var CompanyList = companyRepo.GetList(); ViewBag.CompanyList = new SelectList(CompanyList, "Key", "Value"); var Dtos = companyPerformanceRepo.GetList(sm); var models = Mapper.Map <List <CompanyPerformanceVM> >(Dtos); if (Request.IsAjaxRequest()) { return(PartialView("_List", models)); } return(View(models)); }
public List <CompanyPerformanceDTO> GetList(CompanyPerformanceSM sm) { var sql = @"select b.CompanyName,a.CompanyId,a.CreateDate,a.Creater,a.Id,a.Modifier,a.ModifyDate,a.SalesPerformance,a.UploadDate from EM_Company_Performance a join EM_Company b on a.CompanyId=b.Id where 1=1 "; if (sm.CompanyId != 0) { sql += " and a.CompanyId=@CompanyId "; } if (sm.SDate.HasValue) { sql += " and a.UploadDate>=@SDate "; } if (sm.EDate.HasValue) { sql += " and a.UploadDate<=@EDate "; } var result = DapperHelper.SqlQuery <CompanyPerformanceDTO>(sql, sm).ToList(); return(result); }