Beispiel #1
0
        public async Task Add(GuestAddBindingModel model, ApplicationUser user)
        {
            Guest guest = new Guest
            {
                ApplicationUser = user,
                Nationality     = model.Nationality,
                FirstName       = model.FirstName,
                MiddleName      = model.MiddleName,
                LastName        = model.LastName,
                PersonalIdentificationNumber = model.PersonalIdentificationNumber,
                TelephoneNumber = model.TelephoneNumber,
                Gender          = model.Gender,
                CityTax         = 1, // calculate depending on the age
                BirthDate       = model.BirthDate,
            };

            await this.guestsRepository.AddAsync(guest);

            await this.guestsRepository.SaveChangesAsync();

            await this.guestsReservationsRepository.AddAsync(new GuestReservation
            {
                ReservationId = model.ReservationId,
                GuestId       = guest.Id,
            });

            await this.guestsReservationsRepository.SaveChangesAsync();
        }
Beispiel #2
0
        public ActionResult Add(int id)
        {
            var model = new GuestAddBindingModel();

            model.ReservationId = id;

            return(this.View(model));
        }
Beispiel #3
0
        public async Task <ActionResult> Add(GuestAddBindingModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            var user = await this.userManager.GetUserAsync(this.User);

            try
            {
                await this.guestsService.Add(model, user);
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError(string.Empty, ex.Message);
                return(this.View(model));
            }

            return(this.RedirectToAction("Details", "Reservations", model.ReservationId));
        }