public async Task <IActionResult> OnPostJoinRequestAsync(int notificationId, string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/ViewBilliardClub/" + Id);
            BillardAppDatabaseInitializer _dbinit    = new BillardAppDatabaseInitializer();
            BillardAppIdentityDbContext   _dbContext = new BillardAppIdentityDbContext(_dbinit.setupOptions().Options);

            BilliardClubNotifications notification = _dbContext.BilliardClubNotifications.Single(e => e.id == notificationId);

            var user = _dbContext.Users.Single(e => e.Id == notification.userId);

            BilliardClubUserReference billiardClubUser = new BilliardClubUserReference {
                BilliardAppUserId = user.Id,
                BilliardClubId    = Id,
                Approved          = 1
            };

            if (_dbContext.BilliardClubUsersReference.Find(user.Id, Id) != null)
            {
                StatusMessage = user.Name + " " + user.LastName + " is already a member!!";
                return(LocalRedirect(returnUrl));
            }
            _dbContext.BilliardClubUsersReference.Add(billiardClubUser);

            await _dbContext.SaveChangesAsync();

            StatusMessage = user.Name + " " + user.LastName + " is approved!";

            return(LocalRedirect(returnUrl));
        }
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");

            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }
            string imagePath = "None";

            if (Input.Upload != null)
            {
                Directory.CreateDirectory(Path.Combine(_environment.ContentRootPath, "wwwroot", "images", user.Name + user.LastName + user.Id));
                var file = Path.Combine(_environment.ContentRootPath, "wwwroot", "images", user.Name + user.LastName + user.Id, Input.Upload.FileName);
                imagePath = "~/images/" + user.Name + user.LastName + user.Id + "/" + Input.Upload.FileName;
                using (var fileStream = new FileStream(file, FileMode.Create)) {
                    await Input.Upload.CopyToAsync(fileStream);
                }
                Console.WriteLine(imagePath);
            }
            BillardApp.Areas.Identity.Data.BilliardClubNotifications notifications = new BillardApp.Areas.Identity.Data.BilliardClubNotifications {
                Type            = NotificationType.Created,
                Description     = Notifications.BILLIARD_CLUB_CREATED_0 + " '" + Input.Name + "' " + Notifications.BILLIARD_CLUB_CREATED_1 + " Update it's full address so it's easier to find it!",
                ForBilliardCLub = 0
            };

            BilliardClub billiardClub = new BilliardClub {
                Name            = Input.Name,
                Description     = Input.Description,
                Origin          = Input.Origin,
                Owner           = user.UserName,
                Photo           = imagePath,
                Website         = Input.Website,
                NotificationsFk = 0
            };

            BillardAppDatabaseInitializer _dbinit    = new BillardAppDatabaseInitializer();
            BillardAppIdentityDbContext   _dbContext = new BillardAppIdentityDbContext(_dbinit.setupOptions().Options);

            _dbContext.BilliardClubs.Add(billiardClub);
            _dbContext.BilliardClubNotifications.Add(notifications);
            await _dbContext.SaveChangesAsync();

            BilliardClub refactorBilliardClub = _dbContext.BilliardClubs.Last();

            BillardApp.Areas.Identity.Data.BilliardClubNotifications refactorNotifications = _dbContext.BilliardClubNotifications.Last();
            refactorBilliardClub.NotificationsFk  = refactorNotifications.id;
            refactorNotifications.ForBilliardCLub = refactorBilliardClub.id;

            BilliardClubUserReference billiardClubUser = new BilliardClubUserReference {
                BilliardAppUserId = user.Id,
                BilliardClubId    = refactorBilliardClub.id,
                Approved          = 1
            };

            _dbContext.BilliardClubUsersReference.Add(billiardClubUser);

            await _dbContext.SaveChangesAsync();

            return(LocalRedirect(returnUrl));
        }