Exemplo n.º 1
0
        public static void ForgotPasswordNotificationEmailGen(SendEmailCommandRequest request, Email newEmail, DvtDatabaseContext dbContext, IApiInfrastructure apiInfrastructure)
        {
            var token = dbContext.Token.Include(o => o.Id).Single(o => o.Id == request.TransferObject.TokenId);

            var model = new ForgotPasswordModel
            {
                Name    = token.User.FirstName,
                HostUrl = apiInfrastructure.ApiConfiguration.GetAppSetting("HostUrl"),
                Token   = token.Value.ToString()
            };
            var emailBody = CompileEmailTemplate.Compile(model, "ForgotPassword.cshtml");

            newEmail.Body    = emailBody;
            newEmail.Subject = "Password Reset";
            newEmail.To      = token.User.Email;
        }
Exemplo n.º 2
0
        public static void NewUserAddEmailGen(SendEmailCommandRequest request, Email email, DvtDatabaseContext dbContext, IApiInfrastructure apiInfrastructure)
        {
            var user  = dbContext.UserAccount.Include(g => g.Token).Single(f => f.UserAccountId == request.TransferObject.UserAccountId);
            var model = new NewUserAddModel
            {
                Name    = user.FirstName,
                Email   = user.Email,
                HostUrl = apiInfrastructure.ApiConfiguration.GetAppSetting("HostUrl"),
                Token   = user.Token.Single(g => g.ExpiryDate > apiInfrastructure.Clock.NowAsSouthAfrican && g.TokenTypeId == (int)TokenType.SetPassword).Value.ToString()
            };

            var emailBody = CompileEmailTemplate.Compile(model, "NewUserAdd.cshtml");

            email.Body    = emailBody;
            email.Subject = "User Invitation";
            email.To      = user.Email;
        }