Exemple #1
0
        public async Task <IActionResult> Create(HotelCreateInputModel input)
        {
            var user = await this.userManager.GetUserAsync(this.User);

            if (user.HotelId != null)
            {
                return(this.RedirectToAction("Index"));
            }

            if (!this.ModelState.IsValid)
            {
                input.Cities = this.citiesService.GetAll <CityDropDownViewModel>();
                input.Stars  = this.starsService.GetAll <StarsDropDownViewModel>();

                return(this.View(input));
            }

            await this.hotelsService.CreateAsync(
                input.Name,
                input.CityId,
                input.Address,
                input.StarsId,
                input.CleaningPerDays,
                user);

            await this.userManager.AddToRoleAsync(user, GlobalConstants.ManagerRoleName);

            await this.signInManager.SignOutAsync();

            return(this.RedirectToAction("Index"));
        }
Exemple #2
0
        public async Task <IActionResult> Create()
        {
            var user = await this.userManager.GetUserAsync(this.User);

            if (user.HotelId != null)
            {
                return(this.RedirectToAction("Index"));
            }

            var cities = this.citiesService.GetAll <CityDropDownViewModel>();
            var stars  = this.starsService.GetAll <StarsDropDownViewModel>();

            var viewModel = new HotelCreateInputModel
            {
                Cities = cities,
                Stars  = stars,
            };

            return(this.View(viewModel));
        }