public ActionResult Index() { string[] regions = locationService.GetRegionList("name"); string[] ids = locationService.GetRegionList("id"); ViewBag.Regions = regions; ViewBag.Ids = ids; var config = new MapperConfiguration(cfg => cfg.CreateMap <KindDTO, KindVM>()); var mapper = config.CreateMapper(); var kinds = mapper.Map <IEnumerable <KindDTO>, IEnumerable <KindVM> >(kindService.GetKinds()); return(View(kinds)); }
public ActionResult BasicAdInformationEdit(int AdId) { var configAd = new MapperConfiguration(cfg => { cfg.CreateMap <AdDTO, AdVM>(); cfg.CreateMap <KindDTO, KindVM>(); cfg.CreateMap <CategoryDTO, CategoryVM>(); cfg.CreateMap <LocationDTO, LocationVM>(); cfg.CreateMap <UserDTO, UserVM>() .ForMember("ConfirmPassword", opt => opt.Ignore()); cfg.CreateMap <TagDTO, TagVM>() .ForMember(t => t.InfoReviewTags, p => p.Ignore()); cfg.CreateMap <ImageDTO, ImageVM>(); }); //configAd.AssertConfigurationIsValid(); var mapperAd = configAd.CreateMapper(); var ad = mapperAd.Map <AdDTO, AdVM>(adService.GetAdbyAdId(AdId)); var configKind = new MapperConfiguration(cfg => cfg.CreateMap <KindDTO, KindVM>()); var mapperKind = configKind.CreateMapper(); var kinds = mapperKind.Map <IEnumerable <KindDTO>, IEnumerable <KindVM> >(kindService.GetKinds()); SelectList kindsDD = new SelectList(kinds, "KindId", "Name", ad.Kind.Name); ViewBag.Kinds = kindsDD; kindService.Dispose(); var configCategory = new MapperConfiguration(cfg => cfg.CreateMap <CategoryDTO, CategoryVM>()); var mapperCategory = configCategory.CreateMapper(); var categories = mapperCategory.Map <IEnumerable <CategoryDTO>, IEnumerable <CategoryVM> >(categoryService.GetCategories()); SelectList categoryDD = new SelectList(categories, "CategoryId", "Name", ad.Category.Name); ViewBag.Categories = categoryDD; categoryService.Dispose(); var configLocation = new MapperConfiguration(cfg => cfg.CreateMap <LocationDTO, LocationVM>()); var mapperLocation = configLocation.CreateMapper(); var locations = mapperLocation.Map <IEnumerable <LocationDTO>, IEnumerable <LocationVM> >(locationService.GetLocations()); SelectList locationDD = new SelectList(locations, "LocationId", "LocationName", ad.LocationNew.LocationName); ViewBag.Locations = locationDD; locationService.Dispose(); return(PartialView(ad)); }