public async Task SendEmail(User beforeInsertUserData, User afterInsertUserData, string email)
        {
            //Generate hash data for confirm email
            string hashConfirmData =
                EmailConfirmHelper.GetHash(beforeInsertUserData.Id, afterInsertUserData.IsEmailValid, afterInsertUserData.Email);
            string linkConfirm =
                EmailConfirmHelper.GetLink("https://bookingsectors.azurewebsites.net", afterInsertUserData.Email, hashConfirmData);

            //Send email
            string emailMessage =
                EmailBody.Registration.GetBodyMessage(afterInsertUserData.Lastname, beforeInsertUserData.Phone, linkConfirm);

            EmailSender sender = new EmailSender(emailMessage);

            await sender.SendAsync("Registration in Booking Fishing Sectors",
                                   email,
                                   $"{afterInsertUserData.Lastname} {afterInsertUserData.Firstname}");
        }
        public async Task SendEmail(User beforeInsertUserData, User afterInsertUserData, string email)
        {
            //generate hash data for confirm email
            string hashconfirmdata =
                EmailConfirmHelper.GetHash(beforeInsertUserData.Id, afterInsertUserData.Verification, afterInsertUserData.Email);
            string linkconfirm =
                EmailConfirmHelper.GetLink("https://localhost:4200", afterInsertUserData.Email, hashconfirmdata);

            //Send email
            string emailMessage =
                EmailBody.Registration.GetBodyMessage(afterInsertUserData.Name, beforeInsertUserData.Email, linkconfirm);

            EmailSender sender = new EmailSender(emailMessage);

            await sender.SendAsync("Registration in QuiZone",
                                   email,
                                   $"{afterInsertUserData.Name} {afterInsertUserData.Surname}");
        }
        public async Task <bool> ConfirmEmailAsync(UserDTO userDTO, string hash)
        {
            string hashConfirmData = EmailConfirmHelper.GetHash(userDTO.Id, userDTO.Verification, userDTO.Email);
            bool   isHashEqual     = EmailConfirmHelper.EqualHash(hash, hashConfirmData);


            if (!isHashEqual)
            {
                return(false);
            }

            var existedUser = await database.UserRepository.GetByIdAsync(userDTO.Id);

            existedUser.Verification = true;
            var  updatedUser = database.UserRepository.Update(existedUser);
            bool isSave      = await database.SaveAsync();

            return(isSave);
        }
        public async Task <bool> ConfirmEmailAsync(UserDTO userDTO, string hash)
        {
            string hashConfirmData = EmailConfirmHelper.GetHash(userDTO.Id, userDTO.IsEmailValid, userDTO.Email);
            bool   isHashEqual     = EmailConfirmHelper.EqualHash(hash, hashConfirmData);


            if (isHashEqual)
            {
                var existedUser = await database.UserRepository.GetEntityByIdAsync(userDTO.Id);

                existedUser.IsEmailValid = true;
                var  updatedUser = database.UserRepository.UpdateEntity(existedUser);
                bool isSave      = await database.SaveAsync();


                return(isSave);
            }

            return(false);
        }