public async Task <IActionResult> NewGuest(string reservationId) { if (!await this.IsValidReservation(reservationId)) { return(this.NotFound()); } var cities = this.citiesService.GetAll <CityDropDownViewModel>(); var countries = this.countriesService.GetAll <CountryDropDownViewModel>(); var genders = this.gendersService.GetAll <GenderDropDownViewModel>(); var viewModel = new GuestsCreateInputModel { Cities = cities, Countries = countries, Genders = genders, ReservationId = reservationId, }; return(this.View(viewModel)); }
public async Task <IActionResult> NewGuest(GuestsCreateInputModel input) { if (!await this.IsValidReservation(input.ReservationId)) { return(this.NotFound()); } if (!this.ModelState.IsValid || input.IdentificationNumber == null && input.UniqueNumberForeigner == null || input.CityId == null && input.CountryId == null) { var cities = this.citiesService.GetAll <CityDropDownViewModel>(); var countries = this.countriesService.GetAll <CountryDropDownViewModel>(); var genders = this.gendersService.GetAll <GenderDropDownViewModel>(); input.Cities = cities; input.Countries = countries; input.Genders = genders; return(this.View(input)); } await this.guestsService.CreateAsync( input.FirstName, input.LastName, input.GenderId, input.PhoneNumber, input.CityId, input.CountryId, input.IdentificationNumber, input.UniqueNumberForeigner, input.DocumentNumber, input.DateOfExpiry, input.DateOfIssue, input.ReservationId); return(this.RedirectToAction("Details", "Reservations", new { Id = input.ReservationId })); }