Ejemplo n.º 1
0
        ///<summary>
        /// 发送
        ///</summary>
        ///<example>
        /// <code>
        ///     var Email = new Email("smtp.gmail.com", 587);
        ///     Email
        ///         .From("Andre Carrilho", "*****@*****.**")
        ///         .To(to => to.Add("Andre Carrilho", "*****@*****.**"))
        ///         .Bcc(bcc => bcc.Add(mailsWithDisplayNames))
        ///         .Cc(cc => cc.Add(justMails))
        ///         .Body("Trying out the Email class with some Html: &lt;p style='font-weight:bold;color:blue;font-size:32px;'>html&lt;/p>")
        ///         .Subject("Testing Fluent Email")
        ///         .IsBodyHtml(true)
        ///         .Credentials("someUser", "somePass")
        ///         .Port(1234)
        ///         .Ssl(true)
        ///         .Send();
        /// </code>
        ///</example>
        ///<returns>true/false</returns>
        public bool Send()
        {
            if (linkeds.Count > 0)
            {
                AlternateView htmlBody = AlternateView.CreateAlternateViewFromString(Message.Body, null, "text/html");
                foreach (var info in linkeds)
                {
                    htmlBody.LinkedResources.Add(info);
                }
                Message.AlternateViews.Add(htmlBody);
                linkeds.Clear();
            }
            errorMessage = string.Empty;
            if (isSend)
            {
                try {
                    smtpClient.Send(message);
                    return(true);
                } catch (Exception ex) {
                    errorMessage = ex.ToExceptionDetail();
                    return(false);
                }
            }
            bool isTrue = email.Send(message, smtpClient);

            if (!isTrue)
            {
                errorMessage = email.ErrorMessage;
            }
            return(isTrue);
        }
        public string SendNewMsg(APAPMessage apapMsg, IEmail Email)
        {
            string returnMessage;
            var    PushToAPAP        = new apapws();
            string UpdateLinkToEmail = CreateUpdateLink(apapMsg);

            try
            {
                string Body       = "";
                string CallResult = PushToAPAP.UpdateUserInfo(apapMsg.szUserID, apapMsg.szRegType, apapMsg.szSpouseRegFlag, apapMsg.szFirstTimeFlag, apapMsg.szVolunteerFlag, apapMsg.szHeardAboutEvent, apapMsg.szExcludeEmailFlag, apapMsg.szAttendLuncheonFlag, apapMsg.szNumTicketsPurchased, apapMsg.szSponsorAwardTableFlag, apapMsg.szPaymentMethod, apapMsg.szRegID, apapMsg.szJobTitle, apapMsg.szPerID, DateTime.Today);


                returnMessage = CallResult;
                if (CallResult.Length > 150)
                {
                    Body = "Failed to Update APAP Member " + " at " + DateTime.Now + '\n' + CallResult + "\n" + UpdateLinkToEmail;
                    Email.UpdateSubject("APAP Post to ProTech Failed");
                }

                else
                {
                    Body = "Succeeded to Update APAP Member " + " at " + DateTime.Now + '\n' + CallResult + "\n" + UpdateLinkToEmail;
                    Email.UpdateSubject("APAP Post to ProTech Succeeded");
                }
                bool result = Email.Send("*****@*****.**", Body);
            }
            catch (Exception e)
            {
                string Body   = "Error occured " + " at " + DateTime.Now + ". This call was not made: " + UpdateLinkToEmail + '\n' + " Message: " + e.Message + " InnerException: " + e.InnerException + " StackTrace: " + e.StackTrace;
                bool   result = Email.Send("*****@*****.**", Body);
                returnMessage = e.ToString();
            }
            return(returnMessage);
        }
        public IHttpActionResult PostStudent(UserEntryModel userModel)
        {
            var newStudent = new User();

            _studentsServices.Map(newStudent, userModel);
            _studentsServices.Add(newStudent);
            var stringparameter = _encryption.Encrypt(newStudent.AccountId);

            _email.Send(newStudent.Email, "Hacer click en el siguiente link para activar su cuenta: " + HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/api/Students/" + HttpContext.Current.Server.UrlEncode(stringparameter) + "/Active", "Vinculación");
            return(Ok(newStudent));
        }
        private void sendMail(OrderDto orderDto)
        {
            string emailbody;

            emailbody = "<br><br><table border='1'>" +
                        "<tr>" +
                        "<th>UserName</th>" +
                        "<th>Address</th>" +
                        "<th>Diate</th>" +
                        "<th>Total</th>" +
                        "</tr>" +
                        "<tr>" +
                        "<td>" + orderDto.UserName + "</td>" +
                        "<td>" + orderDto.Address + "</td>" +
                        "<td>" + orderDto.Date + "</td>" +
                        "<td>" + orderDto.Total + "</td>" +
                        "</tr>" +
                        "</table><br><br>" + "Item Purchase";

            List <OrderItemDto> orderItemDto = orderDto.OrderItemDto;

            for (int i = 0; i < orderItemDto.Count; i++)
            {
#pragma warning disable S1643 // Strings should not be concatenated using '+' in a loop
                emailbody += "<table>" +
                             "<tr>" +
                             "<td>" + "Name: " + orderItemDto[i].Name + "</td>" +
                             "<td>" + " Price: " + orderItemDto[i].ProductPrice + "</td>" +
                             "</tr>" +
                             "</table>";
#pragma warning restore S1643 // Strings should not be concatenated using '+' in a loop
            }

            _email.Send(orderDto.Email, "Home Shop - Bill", emailbody);
        }
Ejemplo n.º 5
0
        public IHttpActionResult PostStudent(UserEntryModel userModel)
        {
            var newStudent = new User();

            _studentsServices.Map(newStudent, userModel);
            _studentsServices.Add(newStudent);
            var stringparameter = HexadecimalEncoding.ToHexString(newStudent.AccountId);

            _email.Send(newStudent.Email,
                        "Hacer click en el siguiente link para activar su cuenta: " +
                        backEndSite +
                        "/api/Students/" + HttpContext.Current.Server.UrlEncode(stringparameter) +
                        "/Active",
                        "Vinculación");
            return(Ok(newStudent));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            var user = await _userManager.FindByEmailAsync(model.Email);

            if (user != null || user.EmailConfirmed)
            {
                //Send Email
                var token = await _userManager.GeneratePasswordResetTokenAsync(user);

                var changePasswordUrl = Request.Headers["changePasswordUrl"];//http://localhost:4200/change-password

                var uriBuilder = new UriBuilder(changePasswordUrl);
                var query      = HttpUtility.ParseQueryString(uriBuilder.Query);
                query["token"]   = token;
                query["userid"]  = user.Id;
                uriBuilder.Query = query.ToString();
                var urlString = uriBuilder.ToString();

                var emailBody = $"Click on link to change password </br>{urlString}";
                await _email.Send(model.Email, emailBody, _emailOptions.Value);

                return(Ok());
            }

            return(Unauthorized());
        }
        public Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogDebug($"Starting with arguments: {string.Join(" ", Environment.GetCommandLineArgs())}");

            _appLifetime.ApplicationStarted.Register(() =>
            {
                Task.Run(async() =>
                {
                    List <ApifyTaskResult> tasksList = new List <ApifyTaskResult>();
                    try
                    {
                        foreach (string task in _earConfig.Value.Tasks)
                        {
                            var lastTask = await _askApifyapi.GetLastRunningTask(task);
                            tasksList.Add(await _askApifyapi.GetApifyTaskResult(task, MimeTypeEnum.html));
                            tasksList.Add(await _askApifyapi.GetApifyTaskResult(task, MimeTypeEnum.xlsx));
                        }

                        await _email.Send(tasksList);
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex, "Unhandled exception!");
                    }
                    finally
                    {
                        _appLifetime.StopApplication();
                    }
                });
            });

            return(Task.CompletedTask);
        }
Ejemplo n.º 8
0
        public override void Execute(Quartz.IJobExecutionContext context)
        {
            if (context.ScheduledFireTimeUtc.HasValue)
            {
                DateTimeOffset scheduledTime   = context.ScheduledFireTimeUtc.Value;
                DateTime       easternDateTime = TimeZoneInfo.ConvertTimeFromUtc(scheduledTime.UtcDateTime, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));

                // If it's the weekend, don't send email
                if (easternDateTime.DayOfWeek == DayOfWeek.Sunday || easternDateTime.DayOfWeek == DayOfWeek.Saturday)
                {
                    return;
                }

                // Is today a stock market holiday?
                if (this.IsStockMarketHoliday(easternDateTime))
                {
                    return;
                }
            }

            IEnumerable <IUser> usersWithActiveSubscription = _database.GetActiveUsersWantingToReceiveAlerts;

            // Get the email
            IEmail morningMarketAlertEmail = _emailFactory.CreateEmail(
                contents: this.GetEmailContents(),
                subject: "Market Alert",
                // recipients: new List<IEmailRecipient>() { new EmailRecipient() { Name = "Mohammad Mohammadi", EmailAddress = "*****@*****.**" },
                // new EmailRecipient() { Name = "Mehdi Ghaffari", EmailAddress = "*****@*****.**" },
                // new EmailRecipient() { Name = "Ameen Tayyebi", EmailAddress = "*****@*****.**" } });
                recipients: usersWithActiveSubscription);

            morningMarketAlertEmail.Send();
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create(LoginViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Invalid user details");
                return(View(model));
            }

            if (!await _roleInManager.RoleExistsAsync("Editor"))
            {
                await _roleInManager.CreateAsync(new IdentityRole("Editor"));
            }

            var user = new IdentityUser
            {
                UserName = model.Email,
                Email    = model.Email
            };
            var result = await _userManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, $"{error.Code}:{error.Description}");
                }
                return(View());
            }

            // It does make any sense this because the user is new
            //if (!User.IsInRole("Editor"))
            //{
            //    await _userManager.AddToRoleAsync(user, "Editor");
            //}
            await _userManager.AddToRoleAsync(user, "Editor");

            //await _userManager.AddToRolesAsync(user, new[] {"Editor","Creator"});

            var          token     = _userManager.GenerateEmailConfirmationTokenAsync(user);
            var          scheme    = Url.ActionContext.HttpContext.Request.Scheme;
            var          url       = Url.Action("Confirmation", "Logins", new { id = user.Id, token = token.Result }, scheme);
            var          emailBody = $"Please, confirm your email by clicking on the link below<br>{url}";
            const string subject   = "Please, confirm your email address!";
            await _email.Send(model.Email, emailBody, subject);

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Create(LoginViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Invalid user details");
                return(View(model));
            }

            if (!(await _roleManager.RoleExistsAsync("Editor")))
            {
                await _roleManager.CreateAsync(new IdentityRole("Editor"));
            }

            var user = new IdentityUser
            {
                UserName = model.Email,
                Email    = model.Email,
            };


            var result = await _userManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, $"{error.Code} : {error.Description}");
                }

                return(View(model));
            }

            //if (!User.IsInRole("Editor"))
            //{
            //    await _userManager.AddToRoleAsync(user, "Editor");
            //}

            var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);

            var url = Url.Action("Confirmation", "Logins", new { id = user.Id, @token = token });

            var emailBody = $"Please Confirm your email by clicking on the link below <br/><br/> {url}";

            await _emailService.Send(model.Email, emailBody);

            return(RedirectToAction("Index", "Logins"));
        }
    public void DoSomethingThatCausesAnEmailToGetSent()
    {
        var message = new Message {
            To = "*****@*****.**", Body = "Hi, Bob!"
        };

        _email.Send(message);
    }
Ejemplo n.º 12
0
        public async Task <ActionResult <Friend> > PostFriend(FriendRequest request)
        {
            Member member = GetAuthenticatedMember();

            foreach (var email in request.FriendEmails)
            {
                if (string.IsNullOrEmpty(email))
                {
                    return(BadRequest("Invalid email value retrieved!"));
                }

                // do not allow members to send themselves a FR
                if (email == member.Email)
                {
                    continue;
                }

                Member friend = _context.Members.FirstOrDefault(m => m.Email == email);

                // user with that email doesn't exist yet, add it to db and send link to email address to create account
                if (friend == null)
                {
                    // create new account with this email
                    friend = new Member
                    {
                        Email       = email,
                        CreationKey = Guid.NewGuid().ToString()
                    };
                    _context.Members.Add(friend);
                    await _context.SaveChangesAsync();

                    // send invitation email
                    _mailClient.Send(
                        "*****@*****.**",
                        email,
                        "Strawpolly invitation link",
                        $"Hello,\n\nPlease click the link below to create a Strawpolly account:\n\n{_appSettings.FrontEndUrl}/register/{friend.CreationKey}"
                        );
                }

                // insert pending friend request into db if they are not in the friends table yet
                if (!AreFriends(member, friend))
                {
                    _context.Friends.Add(new Friend
                    {
                        MemberID            = member.MemberID,
                        MemberFriendID      = friend.MemberID,
                        MemberWhoModifiedID = member.MemberID,
                        FriendStatus        = FriendStatus.Pending
                    });
                }
            }

            await _context.SaveChangesAsync();

            return(Ok());
        }
        public override void Execute(IJobExecutionContext context)
        {
            // Grab a list of users who have not signed up after their trial expiry for more than 5 days
            List <IUser> lostUsers = (from user in _database.GetUsers
                                      where user.TrialExpiryDate < DateTime.UtcNow &&
                                      !user.SubscriptionId.HasValue &&
                                      !user.SubscriptionExpiryDate.HasValue &&
                                      !user.SentFeedbackRequest &&
                                      EntityFunctions.DiffDays(user.TrialExpiryDate, DateTime.UtcNow) > 5
                                      select user).ToList();

            // Generate email body content
            // TODO EmailResult emailContents = _accountEmailFactory.LostUserFeedback();

            // Create email and send
            IEmail feedbackEmail = _emailFactory.CreateEmail(
                contents: this.GetEmailContents(),
                subject: "Feedback Request",
                sender: new EmailSender()
            {
                Name = "Stockwinners.com", EmailAddress = "*****@*****.**"
            },                                                                                                   // Send from [email protected] so that the user can reply back
                recipients: lostUsers);

            feedbackEmail.Send();

            // Mark that email has been sent to users
            foreach (var user in lostUsers)
            {
                user.SentFeedbackRequest = true;
            }
            _database.SaveChanges();

            // Notify admins
            StringBuilder adminEmailContents = new StringBuilder();

            adminEmailContents.Append("<html><head></head><body>Fellow admins, I just emailed ");
            adminEmailContents.Append(lostUsers.Count);
            adminEmailContents.Append(" users and asked them for feedback. These folks have chosen not to sign up after 5 days after their trial expiry date. Here is the list:<br/><br>");

            foreach (var user in lostUsers)
            {
                adminEmailContents.Append(user.FirstName);
                adminEmailContents.Append(" ");
                adminEmailContents.Append(user.LastName);
                adminEmailContents.Append(" ");
                adminEmailContents.Append(user.EmailAddress);
                adminEmailContents.Append("<br/>");
            }

            adminEmailContents.Append("<br/>Adios!</body></html>");

            IEmail adminNotification = _emailFactory.CreateEmailForAdministrators(adminEmailContents.ToString(), "Feedback Request " + DateTime.UtcNow.ToShortDateString());

            adminNotification.Send();
        }
Ejemplo n.º 14
0
        public IHttpActionResult PostUser(ProfessorEntryModel professorModel)
        {
            var professor = new User();

            _professorsServices.Map(professor, professorModel);
            _professorsServices.AddProfessor(professor);
            var accountIdParameter = _encryption.Encrypt(professor.AccountId);

            _email.Send(professor.Email
                        , "Hacer click en el siguiente link para establecer su contraseña : http://fiasps.unitec.edu:8096/registro-maestro/" + HttpContext.Current.Server.UrlEncode(accountIdParameter)
                        , "Vinculacion");
            return(Ok(professor));
        }
Ejemplo n.º 15
0
        public override void Execute(IJobExecutionContext context)
        {
            // Get the list of users who have an active trial and have not logged in for more than 5 days
            List <IUser> inactiveUsers = (from user in _database.GetUsers
                                          where !user.SubscriptionId.HasValue && user.TrialExpiryDate > DateTime.UtcNow &&
                                          EntityFunctions.DiffDays(user.LastLoginDate, DateTime.UtcNow) >= 5 &&
                                          !user.SentInactiveReminder
                                          select user).ToList();

            // Generate email for inactive members
            // TODO: EmailResult emailContents = _accountEmailFactory.InactiveTrialAccount();
            IEmail inactiveUserEmail = _emailFactory.CreateEmail(
                contents: this.GetEmailContents(),
                subject: "Inactive Trial Account",
                recipients: inactiveUsers);

            // Send the email to users
            inactiveUserEmail.Send();

            // Mark the users so that they don't get duplicate notifications
            foreach (var user in inactiveUsers)
            {
                user.SentInactiveReminder = true;
            }
            _database.SaveChanges();

            // Notify dear admins
            StringBuilder adminEmailContents = new StringBuilder();

            adminEmailContents.Append("<html><head></head><body>Fellow admins, your server over here speaking. I just reminded ");
            adminEmailContents.Append(inactiveUsers.Count);
            adminEmailContents.Append(" users that they have been inactive for more than 5 days. Here is who I sent email to:<br/><br/>");

            foreach (IUser user in inactiveUsers)
            {
                adminEmailContents.Append(user.FirstName);
                adminEmailContents.Append(" ");
                adminEmailContents.Append(user.LastName);
                adminEmailContents.Append(" ");
                adminEmailContents.Append(user.EmailAddress);
                adminEmailContents.Append("<br/>");
            }

            adminEmailContents.Append("I'm going to go sleep for another day now.</body></html>");

            IEmail adminNotificationEmail = _emailFactory.CreateEmailForAdministrators(adminEmailContents.ToString(), "Inactive Users Report " + DateTime.UtcNow.ToShortDateString());

            adminNotificationEmail.Send();
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> Create(CreateEmployerViewModel model)
        {
            if (!(await _roleManager.RoleExistsAsync("Employer")))
            {
                await _roleManager.CreateAsync(new IdentityRole("Employer"));
            }
            var employer = new User
            {
                UserName = model.Username,
                Email    = model.Email
            };
            var result = await _userManager.CreateAsync(employer, model.Password);

            if (!result.Succeeded)
            {
                return(BadRequest(result));
            }

            //Send Email
            var token = await _userManager.GenerateEmailConfirmationTokenAsync(employer);

            var confirmEmailUrl = Request.Headers["confirmEmailUrl"];//http://localhost:4200/email-confirm

            var uriBuilder = new UriBuilder(confirmEmailUrl);
            var query      = HttpUtility.ParseQueryString(uriBuilder.Query);

            query["token"]   = token;
            query["userid"]  = employer.Id;
            uriBuilder.Query = query.ToString();
            var urlString = uriBuilder.ToString();

            var emailBody = $"Please confirm your email by clicking on the link below </br>{urlString}";
            await _email.Send(model.Email, emailBody, _emailOptions.Value);

            //////////////////

            var userFromDb = await _userManager.FindByNameAsync(employer.UserName);

            await _userManager.AddToRoleAsync(userFromDb, "Employer");

            return(Ok(result));
        }
Ejemplo n.º 17
0
        private void SendNotification(Order order, int orderId)
        {
            // This can be queued and send it by diffent service (communication service)
            TemplateResult templateResult = _emailTemplate.GetInvoiceEmailMessage(order, orderId);
            EmailMessage   emailMessage   = new EmailMessage
            {
                ToAddress = new string[] { order.Buyer.Email }
            };

            try
            {
                // TODO: async
                _email.Send(emailMessage);
            }
            catch (Exception)
            {
                // DONT RETHROW HERE
                // TODO: handle exception and log it, ensure retry/queue it for sending message
            }
        }
Ejemplo n.º 18
0
        public override void Execute(IJobExecutionContext context)
        {
            // Check today's time and find all users whose trial expiry is today
            // Look up all users whose trial expires today
            List <IUser> usersWithSuspendedPayment = _database.GetUsersWithSuspendedPayments.ToList();

            // Get the email
            IEmail paymentSuspendedEmail = _emailFactory.CreateEmail(
                contents: this.GetEmailContents(),
                subject: "Subscription Suspended",
                recipients: usersWithSuspendedPayment);

            // Finally send the email
            paymentSuspendedEmail.Send();

            // Now let the admins know about the email sent
            IEmail adminNotificationEmail = _emailFactory.CreateEmailForAdministrators(
                this.GenerateAdminNotificationEmail(usersWithSuspendedPayment),
                "Users With Suspended Payment Report " + DateTime.UtcNow.ToShortDateString());

            adminNotificationEmail.Send();
        }
Ejemplo n.º 19
0
        public override void Execute(IJobExecutionContext context)
        {
            // Check today's time and find all users whose trial expiry is today
            // Look up all users whose trial expires today
            List <IUser> usersWithExpiredTrial = (from user in _database.GetUsers
                                                  where !user.SubscriptionId.HasValue &&
                                                  EntityFunctions.DiffDays(user.TrialExpiryDate, EntityFunctions.CreateDateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 0, 0, 0)) == 0 &&
                                                  !user.SentTrialExpiryEmail
                                                  select user).ToList();

            // Generate the email contents
            // TODO
            // EmailResult trialExpiredEmailContents = _accountEmailFactory.TrialExpired();

            // Get the email
            IEmail trialExpiredEmail = _emailFactory.CreateEmail(
                contents: this.GetEmailContents(),
                subject: "Trial Membership Conclusion",
                recipients: usersWithExpiredTrial);

            // Finally send the email
            trialExpiredEmail.Send();

            // Mark that we have sent the email to the users
            foreach (var user in usersWithExpiredTrial)
            {
                user.SentTrialExpiryEmail = true;
            }
            _database.SaveChanges();

            // Now let the admins know about the email sent
            IEmail adminNotificationEmail = _emailFactory.CreateEmailForAdministrators(
                this.GenerateAdminNotificationEmail(usersWithExpiredTrial),
                "Users With Expired Trial Report " + DateTime.UtcNow.ToShortDateString());

            adminNotificationEmail.Send();
        }
Ejemplo n.º 20
0
 public Task Invoke()
 {
     try
     {
         Loggeding.Info("Init");
         Email.Send("");
         return(Task.CompletedTask);
     }
     catch (Exception ex)
     {
         if (_retry)
         {
             _retry = false;
             Task.Delay(3000);
             Loggeding.Info("Retry");
             return(Invoke());
         }
         else
         {
             Loggeding.Error(ex);
             return(Task.CompletedTask);
         }
     }
 }
Ejemplo n.º 21
0
        public IHttpActionResult EnableProfessor(EnableProfessorModel model)
        {
            /* check if the account Id exists on the system
             *  if exists, check
             *      if the status = inactive (0)
             *          update account information and send email
             *      else
             *          cannot update information
             *  else -> account doesnt exist
             *      create account with the model
             *      send email
             */

            var professor = _professorsServices.FindNullable(model.AccountId);

            // Check if account exists
            if (professor != null)
            {
                // Check if account is inactive
                if (((User)professor).Status == 0)
                {
                    var updatedProfessor = _professorsServices.UpdateProfessor(model.AccountId, model);

                    // Send confirmation email

                    var encryptedTalentoHumano = HexadecimalEncoding.ToHexString(model.AccountId);
                    _email.Send(model.Email,
                                "Hacer click en el siguiente link para activar su cuenta: " +
                                backEndSite +
                                "/api/Professors/EnableProfessors/Activate/" + HttpContext.Current.Server.UrlEncode(encryptedTalentoHumano),
                                "Vinculación");
                    return(Ok());
                }
                else
                {
                    throw new Exception("account is already active");
                }
            }
            else
            {
                var newProfessor = new User();

                //mapeo
                newProfessor.AccountId        = model.AccountId;
                newProfessor.Email            = model.Email;
                newProfessor.Password         = _encryption.Encrypt(model.Password);
                newProfessor.Name             = model.FirstName + " " + model.LastName;
                newProfessor.Major            = null;
                newProfessor.Campus           = "USPS";
                newProfessor.CreationDate     = DateTime.Now;
                newProfessor.ModificationDate = DateTime.Now;
                newProfessor.Status           = Data.Enums.Status.Inactive;
                newProfessor.Finiquiteado     = false;

                _professorsServices.AddProfessor(newProfessor);

                // Send confirmation email
                var encryptedTalentoHumano = HexadecimalEncoding.ToHexString(model.AccountId);
                _email.Send(model.Email,
                            "Hacer click en el siguiente link para activar su cuenta: " +
                            backEndSite +
                            "/api/Professors/EnableProfessors/Activate/" + HttpContext.Current.Server.UrlEncode(encryptedTalentoHumano),
                            "Vinculación");
                return(Ok());
            }
        }
Ejemplo n.º 22
0
 public void Handle(SendEmailCommand command)
 {
     _emailProvider.Send(command.From, command.To, string.Empty, command.EmailSubject, command.EmailBody);
 }