public ActivationResponse ActivateUser(ActivationRequest req) { req.ActivationCode = Cryptography.Decrypt(req.ActivationCode); UserActivation UserAction = _context.UserActivations.Include(x => x.User) .Where(p => p.ActivationCode == req.ActivationCode && p.ActivationType == ActivationType.UserActivation) .Select(s => s).FirstOrDefault(); UserAction.User.Active = true; UserAction.isActivated = true; UserAction.ActivationChannelType = ActivationChannelType.Email; _context.SaveChangesAsync(); return(UserAction.Adapt <ActivationResponse>()); }
private void SetupActivation(Register user) { UserActivation usersActivation = new UserActivation(); usersActivation.User = user; usersActivation.StartTime = DateTime.Now; usersActivation.ActivationCode = GenerateActivationCode(); usersActivation.ActivationType = ActivationType.UserActivation; _mailService.SetActivation(usersActivation.Adapt <Activation>()); _mailService.SetEmailType(EmailType.UserActivation); _mailService.SetMailBoxes = ConvertUserToMailBoxesArray(user); _mailService.SetEmailMessage(); _mailService.SendEmailAsync(); _context.UserActivations.Add(usersActivation); _context.SaveChangesAsync(); }
public ResetPasswordResponse SendResetPasswordMail(ResetPasswordRequest req) { User user = _context.Users.Where(p => p.Email == req.Email && p.Active) .Select(s => s).FirstOrDefault(); UserActivation usersActivation = new UserActivation(); usersActivation.User = user; usersActivation.StartTime = DateTime.Now; usersActivation.ActivationCode = GenerateActivationCode(); usersActivation.ActivationType = ActivationType.PasswordReset; _mailService.SetActivation(usersActivation.Adapt <Activation>()); _mailService.SetEmailType(EmailType.PasswordReset); _mailService.SetMailBoxes = ConvertUserToMailBoxesArray(user); _mailService.SetEmailMessage(); _mailService.SendEmailAsync(); _context.UserActivations.Add(usersActivation); _context.SaveChangesAsync(); ResetPasswordResponse res = new ResetPasswordResponse(); res.isResetMailSent = true; return(res); }