public async Task <IEnumerable <Booking> > PostBookings(BookingUser user)
        {
            var client   = new Unknowntype();
            var bookings = await client.Bookings.GetBookingsWithOperationResponseAsync();

            return(bookings.Body.Where(_ => _.CustomerId == user.UserId).Select(_ => new Booking
            {
                Id = _.Id ?? 0,
                HeroName = _.Heroes.FirstOrDefault()?.Name ?? string.Empty,
                Description = _.Description,
                StartTime = _.StartTime,
                EndTime = _.EndTime,
                Rating = _.CustomerRating ?? 0.0
            }));
        }
Example #2
0
        private async Task LoadSharedKeyAndQrCodeUriAsync(BookingUser user)
        {
            // Load the authenticator key & QR code URI to display on the form
            var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);

            if (string.IsNullOrEmpty(unformattedKey))
            {
                await _userManager.ResetAuthenticatorKeyAsync(user);

                unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);
            }

            this.SharedKey = this.FormatKey(unformattedKey);

            var email = await _userManager.GetEmailAsync(user);

            this.AuthenticatorUri = this.GenerateQrCodeUri(email, unformattedKey);
        }
Example #3
0
        public async Task <IActionResult> OnPostConfirmationAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");
            // Get the information about the user from the external login provider
            var info = await _signInManager.GetExternalLoginInfoAsync();

            if (info == null)
            {
                this.ErrorMessage = "Error loading external login information during confirmation.";
                return(RedirectToPage("./Login", new { ReturnUrl = returnUrl }));
            }

            if (ModelState.IsValid)
            {
                var user = new BookingUser {
                    UserName = Input.Email, Email = Input.Email
                };
                var result = await _userManager.CreateAsync(user);

                if (result.Succeeded)
                {
                    result = await _userManager.AddLoginAsync(user, info);

                    if (result.Succeeded)
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider);
                        return(LocalRedirect(returnUrl));
                    }
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            LoginProvider = info.LoginProvider;
            ReturnUrl     = returnUrl;
            return(Page());
        }
Example #4
0
 private Booking(int bookingId, int accommId, BookingUser bookingUser, DateTime dateFrom, DateTime dateTo, char status, double priceBasic, double priceSum, int currencyId, string currencyAbrevation,
     int numOfPersons, int numOfBabies, int? promoCodeId, string adminUserName, DateTime dateCreated, DateTime? lastUpdateDate)
 {
     this.BookingId = bookingId;
     this.AccommodationId = accommId;
     this.User = bookingUser;
     this.DateFrom = dateFrom;
     this.DateTo = dateTo;
     this.Status = status;
     this.PriceBasic = priceBasic;
     this.PriceSum = priceSum;
     this.CurrencyId = currencyId;
     this.CurrencyAbreavation = currencyAbrevation;
     this.NumOfPersons = numOfPersons;
     this.NumOfBabies = numOfBabies;
     this.PromoCodeId = promoCodeId;
     this.AdminUserName = adminUserName;
     this.DateCreated = dateCreated;
     this.LastUpdateDate = lastUpdateDate;
 }
Example #5
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");
            if (ModelState.IsValid)
            {
                var user = new BookingUser {
                    FirstName = Input.FirstName, LastName = Input.LastName, UserName = Input.Email, Email = Input.Email
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { userId = user.Id, code = code },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(LocalRedirect(returnUrl));
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Example #6
0
        public async Task SeedAsync(BookingDbContext dbContext, IServiceProvider serviceProvider)
        {
            var userManager = serviceProvider.GetRequiredService <UserManager <BookingUser> >();

            var user = await userManager.FindByEmailAsync("*****@*****.**");

            if (user == null)
            {
                BookingUser demoUser = new BookingUser
                {
                    UserName  = "******",
                    Email     = "*****@*****.**",
                    FirstName = "Demo",
                    LastName  = "Demo"
                };

                await userManager.CreateAsync(demoUser, "123456");
            }
            var user2 = await userManager.FindByNameAsync("*****@*****.**");

            if (user2 == null)
            {
                BookingUser adminUserser = new BookingUser
                {
                    UserName  = "******",
                    Email     = "*****@*****.**",
                    FirstName = "Admin",
                    LastName  = "Admin"
                };

                IdentityResult result = await userManager.CreateAsync(adminUserser, "123456");

                if (result.Succeeded)
                {
                    await userManager.AddToRoleAsync(adminUserser, GlobalConstants.AdministratorRoleName);
                }
            }
        }
Example #7
0
    public bool CompleteInfoInputStep(string firstName, string lastName, string email, string phone, string country, string city, string street, out string errMsg)
    {
        this.User = new BookingUser(firstName, lastName, email, phone, country, city, street);

        if (!this.User.IsValid)
        {
            errMsg = ERR_MSG_INFO_INPUT;
            return false;
        }

        this.BookingStep = BookingStepType.Payment;   // postaviti na iduci step
        errMsg = null;
        return true;
    }