public IActionResult AddHouse(AddOrEditHouseVm model) { if (!ModelState.IsValid) { var houseInfo = houseService.GetHouseInfo(); model.DwellingTypeList = houseInfo.DwellingTypes.Select(c => mapper.Map <DwellingTypeLocalization, SelectListItem>(c)).ToList(); model.ZoneTypeList = houseInfo.Zone.Select(c => mapper.Map <ZoneLocalization, SelectListItem>(c)).ToList(); model.UtilitiesTypeList = houseInfo.Utilities.Select(c => mapper.Map <UtilitiesLocalization, SelectListItem>(c)).ToList(); model.BuildingTypeList = houseInfo.BuildingTypes.Select(c => mapper.Map <BuildingTypeLocalization, SelectListItem>(c)).ToList(); model.HouseStyleTypeList = houseInfo.HouseStyles.Select(c => mapper.Map <HouseStyleLocalization, SelectListItem>(c)).ToList(); model.RoofStyleTypeList = houseInfo.RoofStyles.Select(c => mapper.Map <RoofStyleLocalization, SelectListItem>(c)).ToList(); model.GarageTypeList = houseInfo.GarageTypes.Select(c => mapper.Map <GarageTypeLocalization, SelectListItem>(c)).ToList(); model.HeatingTypeList = houseInfo.HeatingTypes.Select(c => mapper.Map <HeatingTypeLocalization, SelectListItem>(c)).ToList(); model.QualityList = houseInfo.Qualities.Select(c => mapper.Map <QualityLocalization, SelectListItem>(c)).ToList(); model.ConstructionMaterials = houseInfo.ConstructionMaterials.Select(c => mapper.Map <ConstructionMaterial, SelectListItem>(c)).ToList(); return(View(model)); } var house = mapper.Map <AddOrEditHouseVm, House>(model); var result = houseService.AddHouse(house); return(RedirectToAction("Index", "Announcement")); }
public IActionResult AddHouse() { var houseInfo = houseService.GetHouseInfo(); var model = new AddOrEditHouseVm { DwellingTypeList = houseInfo.DwellingTypes.Select(c => mapper.Map <DwellingTypeLocalization, SelectListItem>(c)).ToList(), ZoneTypeList = houseInfo.Zone.Select(c => mapper.Map <ZoneLocalization, SelectListItem>(c)).ToList(), UtilitiesTypeList = houseInfo.Utilities.Select(c => mapper.Map <UtilitiesLocalization, SelectListItem>(c)).ToList(), BuildingTypeList = houseInfo.BuildingTypes.Select(c => mapper.Map <BuildingTypeLocalization, SelectListItem>(c)).ToList(), HouseStyleTypeList = houseInfo.HouseStyles.Select(c => mapper.Map <HouseStyleLocalization, SelectListItem>(c)).ToList(), RoofStyleTypeList = houseInfo.RoofStyles.Select(c => mapper.Map <RoofStyleLocalization, SelectListItem>(c)).ToList(), GarageTypeList = houseInfo.GarageTypes.Select(c => mapper.Map <GarageTypeLocalization, SelectListItem>(c)).ToList(), HeatingTypeList = houseInfo.HeatingTypes.Select(c => mapper.Map <HeatingTypeLocalization, SelectListItem>(c)).ToList(), QualityList = houseInfo.Qualities.Select(c => mapper.Map <QualityLocalization, SelectListItem>(c)).ToList(), ConstructionMaterials = houseInfo.ConstructionMaterials.Select(c => mapper.Map <ConstructionMaterial, SelectListItem>(c)).ToList() }; return(View(model)); }