public static TypeOfHotelDTO MapTypeOfHotelDTO(TypeOfHotelViewModel typeOfHotel) { var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <TypeOfHotelViewModel, TypeOfHotelDTO>(); }); var mapper = configuration.CreateMapper(); var typeOfHotelDTO = mapper.Map <TypeOfHotelViewModel, TypeOfHotelDTO>(typeOfHotel); return(typeOfHotelDTO); }
public ActionResult AddHotel(TypeOfHotelViewModel typeOfHotel) { if (Request.HttpMethod == "POST") { var typeOfHotelDto = MappingViewModel.MapTypeOfHotelDTO(typeOfHotel); _adminService.AddHotel(typeOfHotelDto); return(RedirectToAction("Index", "Home")); } else { return(View()); } }