Пример #1
0
        public async Task ActivateAccount(string activateCode)
        {
            User user;

            user = await _userRepos.FindAsync(u => u.ActivationCode == activateCode);

            if (user == null)
            {
                throw new NotFoundException(msg: "Mã kích hoạt không chính xác");
            }
            user.IsConfirmEmail = true;
            user.IsActive       = true;
            var activeCode = Util.GeneratePassword(new Models.PasswordOptions()
            {
                RequireDigit           = true,
                RequiredLength         = 6,
                RequireLowercase       = true,
                RequireNonAlphanumeric = false,
                RequireUppercase       = true
            });

            user.ActivationCode = activeCode;
            Premises premises = await _premesisRepos.FindAsync(x => x.PremisesId == user.PremisesId);

            premises.IsActive = true;
            await _userRepos.UpdateAsync(user);

            await _premesisRepos.UpdateAsync(premises);
        }
Пример #2
0
        public async Task updatePremisesStatus(int premisesId)
        {
            var premises = await _premisesRepository.GetByIdAsync(premisesId);

            if (premises == null)
            {
                throw new NotFoundException("Không tìm thấy cơ sở");
            }
            if (premises.IsActive)
            {
                premises.IsActive = false;
            }
            else
            {
                premises.IsActive = true;
            }
            await _premisesRepository.UpdateAsync(premises, true);
        }