Ejemplo n.º 1
0
        private async void SendVerificationEmail(DeliveryMan newDeliveryMan, string userId, string code)
        {
            var ip          = UsefulMethods.GetLocalIPAddress();
            var callBackUrl = "http://" + ip + ":51044/api/ConfirmDeliveryManEmail?userId=" + userId + "&code=" + code;

            string parent = Directory.GetParent(Directory.GetCurrentDirectory()).FullName;
            string path;

            path = Path.Combine(parent, "DeliveryApp\\wwwroot\\Templates\\EmailTemplates\\ConfirmRegistration.html");


            var builder = new BodyBuilder();

            using (StreamReader SourceReader = System.IO.File.OpenText(path))
            {
                builder.HtmlBody = SourceReader.ReadToEnd();
            }

            string messageBody = string.Format(
                builder.HtmlBody,
                newDeliveryMan.FirstName + " " + newDeliveryMan.LastName,
                callBackUrl
                );

            await emailSenderService.SendUserConfirmationEmail(
                newDeliveryMan.Email,
                newDeliveryMan.FirstName + " " + newDeliveryMan.LastName,
                messageBody
                );
        }
Ejemplo n.º 2
0
        private async void SendVerificationEmail(Admin admin, string userId, string code, bool editedEmail)
        {
            var callBackUrl = "https://localhost:44352/Account/ConfirmAdminEmail?userId=" + userId + "&code=" + code;

            string parent = Directory.GetParent(Directory.GetCurrentDirectory()).FullName;
            string path;

            if (editedEmail)
            {
                path = Path.Combine(parent, "DeliveryApp\\wwwroot\\Templates\\EmailTemplates\\EditedEmailAddress.html");
            }
            else
            {
                path = Path.Combine(parent, "DeliveryApp\\wwwroot\\Templates\\EmailTemplates\\ConfirmRegistration.html");
            }

            var builder = new BodyBuilder();

            using (StreamReader SourceReader = System.IO.File.OpenText(path))
            {
                builder.HtmlBody = SourceReader.ReadToEnd();
            }

            string messageBody = string.Format(
                builder.HtmlBody,
                admin.FirstName + " " + admin.LastName,
                callBackUrl
                );

            await emailSenderService.SendUserConfirmationEmail(
                admin.Email,
                admin.FirstName + " " + admin.LastName,
                messageBody
                );
        }