public IActionResult Create() { var roomTypes = this.roomTypesService.GetAll <RoomTypeDropDownViewModel>(); var viewModel = new RoomCreateInputModel { RoomTypes = roomTypes, }; return(this.View(viewModel)); }
public async Task <IActionResult> Create(RoomCreateInputModel roomCreateInputModel) { if (!ModelState.IsValid) { await GetAllRoomTypes(); await GetAllDepartments(); return(View(roomCreateInputModel)); } RoomServiceModel roomServiceModel = AutoMapper.Mapper.Map <RoomServiceModel>(roomCreateInputModel); await roomService.Create(roomServiceModel); return(Redirect("All")); }
public async Task <IActionResult> Create(RoomCreateInputModel input) { if (!this.ModelState.IsValid) { var roomTypes = this.roomTypesService.GetAll <RoomTypeDropDownViewModel>(); input.RoomTypes = roomTypes; return(this.View(input)); } var user = await this.userManager.GetUserAsync(this.User); await this.roomsService.CreateAsync( input.Floor, input.Number, input.RoomTypeId, input.Price, input.MaxAdultCount, input.MaxChildCount, input.Description, (int)user.HotelId); return(this.RedirectToAction("AllRooms")); }