Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ChildActionOnly]
- public Expression<Func<TModel, dynamic>>[] GetMapping<TModel>()
- {
- Expression<Func<TModel, dynamic>>[] map = null;
- Type modelType = typeof(TModel);
- object auxMap = null;
- if (modelType == typeof(AssiduityCodesViewModel))
- {
- auxMap =
- CSVMapper.RawMap<AssiduityCodesViewModel>(
- x => x.AssiduityCode
- , x => x.AssiduityCodeErp
- , x => x.AssiduityTypeCode
- , x => x.AssiduityCodeDesc
- , x => x.CompanyName
- , x => x.Vacation
- , x => x.NeedsProof
- , x => x.Active
- );
- }
- else if (modelType == typeof(HolidayViewModel))
- {
- auxMap =
- CSVMapper.RawMap<HolidayViewModel>(
- x => x.HolidayId
- , x => x.HolidayTypeCode
- , x => x.HolidayDay
- , x => x.CompanyCode
- , x => x.MunicipalityCode
- , x => x.CountyCode
- , x => x.CountryCode
- , x => x.Description
- , x => x.YearPlanner
- , x => x.FixedHoliday
- , x => x.Active
- );
- }
- else if (modelType == typeof(HolidayTypeViewModel))
- {
- auxMap =
- CSVMapper.RawMap<HolidayTypeViewModel>(
- x => x.IdHolidayTypeCode
- , x => x.Description
- , x => x.Active
- );
- }
- else if (modelType == typeof(FringeBenefitsViewModel))
- {
- auxMap =
- CSVMapper.RawMap<FringeBenefitsViewModel>(
- x => x.Code
- , x => x.CompanyCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.Value
- , x => x.Limit
- , x => x.IsActive
- );
- }
- else if (modelType == typeof(RelativeViewModel))
- {
- auxMap =
- CSVMapper.RawMap<RelativeViewModel>(
- x => x.RelativeCode
- , x => x.CompanyCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.Active
- );
- }
- else if (modelType == typeof(CountyViewModel))
- {
- auxMap =
- CSVMapper.RawMap<CountyViewModel>(
- x => x.CountyCode
- , x => x.CountryCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.Active
- );
- }
- else if (modelType == typeof(CountryViewModel))
- {
- auxMap =
- CSVMapper.RawMap<CountryViewModel>(
- x => x.CountryCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.Active
- );
- }
- else if (modelType == typeof(RequestTypeViewModel))
- {
- auxMap =
- CSVMapper.RawMap<RequestTypeViewModel>(
- x => x.Id
- , x => x.Name
- , x => x.Description
- , x => x.CompanyCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(FinancialOfficeViewModel))
- {
- auxMap =
- CSVMapper.RawMap<FinancialOfficeViewModel>(
- x => x.FinancialOfficeCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CompanyCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(IncomeCategoryViewModel))
- {
- auxMap =
- CSVMapper.RawMap<IncomeCategoryViewModel>(
- x => x.IncomeCategoryCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CompanyCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(IdCardTypeViewModel))
- {
- auxMap =
- CSVMapper.RawMap<IdCardTypeViewModel>(
- x => x.IdCardTypeCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CompanyCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(DistrictViewModel))
- {
- auxMap =
- CSVMapper.RawMap<DistrictViewModel>(
- x => x.DistrictCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CountryCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(MunicipalityViewModel))
- {
- auxMap =
- CSVMapper.RawMap<MunicipalityViewModel>(
- x => x.MunicipalityCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CountryCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(ResidenceViewModel))
- {
- auxMap =
- CSVMapper.RawMap<ResidenceViewModel>(
- x => x.ResidenceCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CompanyCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(CategoryViewModel))
- {
- auxMap =
- CSVMapper.RawMap<CategoryViewModel>(
- x => x.CategoryCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CompanyCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(AccountTypeViewModel))
- {
- auxMap =
- CSVMapper.RawMap<AccountTypeViewModel>(
- x => x.AccountTypeCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CompanyCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(CurrentAccountTypeViewModel))
- {
- auxMap =
- CSVMapper.RawMap<CurrentAccountTypeViewModel>(
- x => x.CurrentAccountTypeCode
- , x => x.AccountTypeCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CompanyCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(MaritalsViewModel))
- {
- auxMap =
- CSVMapper.RawMap<MaritalsViewModel>(
- x => x.MaritalCode
- , x => x.IrsMaritalCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CompanyCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(IRSMaritalsViewModel))
- {
- auxMap =
- CSVMapper.RawMap<IRSMaritalsViewModel>(
- x => x.IrsMaritalCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CompanyCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(CitiesViewModel))
- {
- auxMap =
- CSVMapper.RawMap<CitiesViewModel>(
- x => x.CityCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CountryCode
- , x => x.Active
- );
- }
- else if (modelType == typeof(BankListViewModel))
- {
- auxMap =
- CSVMapper.RawMap<BankListViewModel>(
- x => x.BankCode
- , x => x.SwiftCode
- , x => x.ErpCode
- , x => x.Description
- , x => x.CompanyCode
- , x => x.Active
- );
- }
- Type type = typeof(Expression<Func<TModel, dynamic>>[]);
- map = (Expression<Func<TModel, dynamic>>[])Convert.ChangeType(auxMap, type);
- return map;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement