sending email completed
This commit is contained in:
parent
6bc624dd70
commit
1f8eb6103c
15 changed files with 695 additions and 68 deletions
|
|
@ -76,8 +76,69 @@ namespace Web.Areas.Admin.Controllers
|
|||
foreach (var user in subscribedUsers)
|
||||
{
|
||||
string confirmationUrl = $"{Request.Scheme}://{Request.Host}/{confirmationPath}?email={user.Email}";
|
||||
string emailBody = $"<h4>Hey {user.Name}</h4><br>{viewModel.Body}<br><h5>Søren Eggert Lundsteen Olsen<br>Seosoft ApS</h5><hr><h6>Hovedgaden 3<br>Jordrup<br>Kolding 6064<br>Denmark</h6><br/><br/><div style='text-align: center;'><a href='{confirmationUrl}' style='display: inline-block; background-color: #6c757d; color: #fff; padding: 4px 8px; text-decoration: none; border-radius: 4px;'>Unsubscribe</a></div>";
|
||||
//string emailBody = $"<h4>Hey {user.Name}</h4><br>{viewModel.Body}<br><h5>Søren Eggert Lundsteen Olsen<br>Seosoft ApS</h5><hr><h6>Hovedgaden 3<br>Jordrup<br>Kolding 6064<br>Denmark</h6><br/><br/><div style='text-align: center;'><a href='{confirmationUrl}' style='display: inline-block; background-color: #6c757d; color: #fff; padding: 4px 8px; text-decoration: none; border-radius: 4px;'>Unsubscribe</a></div>";
|
||||
string emailBody = $@"<head>
|
||||
<meta charset=""UTF-8"">
|
||||
<meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
|
||||
<title>Email Confirmation</title>
|
||||
<style>
|
||||
body {{
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f9f9f9;
|
||||
}}
|
||||
.container {{
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
border: 0.5px solid #ccc;
|
||||
border-radius: 5px;
|
||||
background-color: #f9f9f9;
|
||||
}}
|
||||
h4, h5, h6 {{
|
||||
margin: 0;
|
||||
}}
|
||||
hr {{
|
||||
border: none;
|
||||
border-top: 1px solid #ccc;
|
||||
margin: 10px 0;
|
||||
}}
|
||||
a.button {{
|
||||
display: inline-block;
|
||||
padding: 5px 10px;
|
||||
background-color: #6c757d;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
}}
|
||||
a.button:hover {{
|
||||
background-color: #5a6268;
|
||||
}}
|
||||
a {{
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
}}
|
||||
a:hover {{
|
||||
text-decoration: underline;
|
||||
}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class=""container"">
|
||||
<h4>Hey {user.Name},</h4>
|
||||
<p>{viewModel.Body}</p><br>
|
||||
|
||||
<h5>Søren Eggert Lundsteen Olsen</h5>
|
||||
<h5><a href=""https://www.seosoft.dk/"" target=""_blank"">SeoSoft ApS</a></h5>
|
||||
<hr>
|
||||
<h6>Hovedgaden 3<br>Jordrup<br>Kolding 6064<br>Denmark</h6>
|
||||
<div style=""text-align: center;"">
|
||||
<a href=""{confirmationUrl}"" class=""button"">Unsubscribe</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>";
|
||||
var email = new EmailToSend(user.Email, viewModel.Subject, emailBody);
|
||||
var isSent = await _emailServices.SendConfirmationEmailAsync(email);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
using Data;
|
||||
using Mailjet.Client.Resources;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Model;
|
||||
|
||||
using Services.EmailSend;
|
||||
using Services.Interaces;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Web.ViewModel.QuestionnaireVM;
|
||||
|
||||
|
||||
|
|
@ -17,12 +20,16 @@ namespace Web.Areas.Admin.Controllers
|
|||
private readonly IQuestionnaireRepository _questionnaire;
|
||||
private readonly SurveyContext _context;
|
||||
private readonly IQuestionRepository _question;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IEmailServices _emailServices;
|
||||
|
||||
public QuestionnaireController(IQuestionnaireRepository Questionnaire, SurveyContext Context, IQuestionRepository Question)
|
||||
public QuestionnaireController(IQuestionnaireRepository Questionnaire, SurveyContext Context, IQuestionRepository Question,IConfiguration configuration,IEmailServices emailServices)
|
||||
{
|
||||
_questionnaire = Questionnaire;
|
||||
_context = Context;
|
||||
_question = Question;
|
||||
_configuration = configuration;
|
||||
_emailServices = emailServices;
|
||||
}
|
||||
public IActionResult Index()
|
||||
{
|
||||
|
|
@ -435,5 +442,122 @@ namespace Web.Areas.Admin.Controllers
|
|||
return View(viewModel);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult SendQuestionnaire(int id)
|
||||
{
|
||||
var quesstionnaireFromDb = _questionnaire.GetQuestionnaireWithQuestionAndAnswer(id);
|
||||
var sendquestionviewmodel = new SendQuestionnaireViewModel();
|
||||
|
||||
sendquestionviewmodel.QuestionnaireId = id;
|
||||
ViewBag.questionnaireName = quesstionnaireFromDb.Title;
|
||||
|
||||
return View(sendquestionviewmodel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> SendQuestionnaire(SendQuestionnaireViewModel viewModel)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
|
||||
// Convert the GUID to a string
|
||||
string guidString = guid.ToString();
|
||||
|
||||
// Construct the complete URL with the GUID-style ID
|
||||
|
||||
|
||||
// Build the email body with questionnaire details
|
||||
var questionnairePath = _configuration["Email:Questionnaire"];
|
||||
int surveyId = viewModel.QuestionnaireId;
|
||||
|
||||
var completeUrl = $"{Request.Scheme}://{Request.Host}/{questionnairePath}/{viewModel.QuestionnaireId}";
|
||||
|
||||
|
||||
|
||||
var toEmail = viewModel.Email;
|
||||
var question = _questionnaire.GetQuesById(viewModel.Id);
|
||||
|
||||
var subject = question.Title;
|
||||
|
||||
// Construct the email body with HTML formatting
|
||||
string emailBody = $@"
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
/* Inline CSS styles */
|
||||
body {{
|
||||
font-family: Arial, sans-serif;
|
||||
}}
|
||||
.container {{
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
border: 0.5px solid #ccc;
|
||||
border-radius: 5px;
|
||||
background-color: #f9f9f9;
|
||||
}}
|
||||
.button {{
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
background-color: #007bff;
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
}}
|
||||
.button:hover {{
|
||||
background-color: #0056b3;
|
||||
}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='container'>
|
||||
<h4>Hey {viewModel.Name},</h4>
|
||||
<h5>{subject}</h5>
|
||||
<p>Thank you for participating in our survey. Your feedback is valuable to us.</p>
|
||||
<p>Please click the button below to start the survey:</p><br>
|
||||
<div style='text-align: center;'>
|
||||
<a href='{completeUrl}' class='button'>Start Survey</a>
|
||||
</div><br>
|
||||
|
||||
<p><strong>Søren Eggert Lundsteen Olsen</strong><br>
|
||||
Seosoft ApS<br>
|
||||
<hr>
|
||||
Hovedgaden 3
|
||||
Jordrup<br>
|
||||
Kolding 6064<br>
|
||||
Denmark</p>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>";
|
||||
|
||||
|
||||
// Call the SendConfirmationEmailAsync method to send the email
|
||||
var emailSend = new EmailToSend(toEmail, subject, emailBody);
|
||||
|
||||
bool emailSent = await _emailServices.SendConfirmationEmailAsync(emailSend);
|
||||
|
||||
if (emailSent)
|
||||
{
|
||||
// Email sent successfully
|
||||
// You can redirect to a success page or return a success message
|
||||
TempData["Success"] = "Questionnaire sent successfully";
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Email failed to send
|
||||
// You can return an error message or handle it as needed
|
||||
ModelState.AddModelError(string.Empty, "Failed to send questionnaire via email.");
|
||||
}
|
||||
}
|
||||
|
||||
// If model state is not valid, return the view with validation errors
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,12 +88,12 @@
|
|||
<td class="d-flex justify-content-end">
|
||||
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger btn-s"><i class="bi bi-trash"></i> Delete</a> |
|
||||
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-primary"><i class="bi bi-pencil-square"></i> Edit</a>|
|
||||
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-info btn-s"><i class="bi bi-pencil-square"></i> Details</a>
|
||||
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-info btn-s"><i class="bi bi-pencil-square"></i> Details</a> |
|
||||
<a asp-action="SendQuestionnaire" asp-route-id="@item.Id" class="btn btn-success btn-s"><i class="bi bi-pencil-square"></i> Send</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
|
|
|||
46
Web/Areas/Admin/Views/Questionnaire/SendQuestionnaire.cshtml
Normal file
46
Web/Areas/Admin/Views/Questionnaire/SendQuestionnaire.cshtml
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
@model SendQuestionnaireViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Send";
|
||||
}
|
||||
|
||||
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="card justify-content-center p-4 shadow rounded">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title h5">Send the questionnaire</h5>
|
||||
|
||||
<div class="row">
|
||||
<form asp-action="SendQuestionnaire">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="QuestionnaireId" class="control-label">Questionnaire</label> <!-- Display ViewBag data in the label -->
|
||||
<input type="text" class="form-control" value="@ViewBag.questionnaireName" disabled /> <!-- Display ViewBag data in the disabled textbox -->
|
||||
<span asp-validation-for="QuestionnaireId" class="text-danger"></span>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Name" class="control-label"></label>
|
||||
<input asp-for="Name" class="form-control" />
|
||||
<span asp-validation-for="Name" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Email" class="control-label"></label>
|
||||
<input asp-for="Email" class="form-control" />
|
||||
<span asp-validation-for="Email" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="hidden" asp-for="QuestionnaireId" /> <!-- Use hidden input for QuestionnaireId -->
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Send" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
|
@ -40,8 +40,7 @@
|
|||
<a asp-controller="Questionnaire" asp-action="index"><span class="bi bi-question-circle"></span> Survey</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
<a asp-controller="newsletters" asp-action="index"><i class="bi bi-envelope"></i> Subscibers</a>
|
||||
<a asp-controller="newsletters" asp-action="index"><span class="bi bi-newspaper"></span> Subscibers</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
|
|
|||
34
Web/Controllers/QuestionnaireResponseController.cs
Normal file
34
Web/Controllers/QuestionnaireResponseController.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Services.Interaces;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Web.Controllers
|
||||
{
|
||||
public class QuestionnaireResponseController : Controller
|
||||
{
|
||||
private readonly IQuestionnaireRepository _questionnaireRepository;
|
||||
|
||||
public QuestionnaireResponseController(IQuestionnaireRepository questionnaireRepository)
|
||||
{
|
||||
_questionnaireRepository = questionnaireRepository;
|
||||
}
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult DisplayQuestionnaire(int id)
|
||||
{
|
||||
|
||||
// Retrieve the questionnaire using the numeric ID
|
||||
var questionnaire = _questionnaireRepository.GetQuestionnaireWithQuestionAndAnswer(id);
|
||||
|
||||
|
||||
// Display the questionnaire
|
||||
return View(questionnaire);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -57,25 +57,85 @@ namespace Web.Controllers
|
|||
string confirmationPath = _configuration["Email:ConfirmEmailPath"]; // Retrieve the confirmation path from appsettings
|
||||
|
||||
string confirmationUrl = $"{Request.Scheme}://{Request.Host}/{confirmationPath}?email={email}"; // Construct the confirmation URL
|
||||
// Construct the confirmation URL
|
||||
string body = $@"Dear {senderName},<br><br>
|
||||
Thank you for subscribing. We're thrilled to have you on board!<br><br>
|
||||
To confirm your subscription, please click the following button:<br><br>
|
||||
<a href=""{confirmationUrl}"" style=""display: inline-block; padding: 10px 20px; background-color: #28a745; color: #fff; text-decoration: none;"">Confirm Subscription</a><br><br>
|
||||
If you have any questions or need assistance, feel free to contact us at help@seosoft.dk<br><br>
|
||||
|
||||
<h5>
|
||||
Søren Eggert Lundsteen Olsen<br>
|
||||
Seosoft ApS
|
||||
</h5>
|
||||
string body = $@"<head>
|
||||
<meta charset=""UTF-8"">
|
||||
<meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
|
||||
<title>Email Confirmation</title>
|
||||
<style>
|
||||
body {{
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f9f9f9;
|
||||
}}
|
||||
.container {{
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
border: 0.5px solid #ccc;
|
||||
border-radius: 5px;
|
||||
background-color: #f9f9f9;
|
||||
}}
|
||||
h5, h6 {{
|
||||
margin:0;
|
||||
}}
|
||||
hr {{
|
||||
border: none;
|
||||
border-top: 1px solid #ccc;
|
||||
margin: 10px 0;
|
||||
}}
|
||||
a.button {{
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
background-color: #28a745;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
}}
|
||||
a {{
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
}}
|
||||
a:hover {{
|
||||
text-decoration: underline;
|
||||
}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class=""container"">
|
||||
<p>Dear {senderName},</p>
|
||||
<p>Thank you for subscribing. We're thrilled to have you on board!</p>
|
||||
<p>To confirm your subscription, please click the following button:</p>
|
||||
<p><a href=""{confirmationUrl}"" class=""button"">Confirm Subscription</a></p>
|
||||
<p>If you have any questions or need assistance, feel free to contact us at help@seosoft.dk</p>
|
||||
|
||||
<h5>Søren Eggert Lundsteen Olsen</h5>
|
||||
<h5><a href=""https://www.seosoft.dk/"" target=""_blank"">SeoSoft ApS</a></h5>
|
||||
<hr>
|
||||
<h6>
|
||||
Hovedgaden 3
|
||||
Jordrup<br>
|
||||
Kolding 6064<br>
|
||||
Denmark
|
||||
</6>
|
||||
";
|
||||
<h6>Hovedgaden 3 Jordrup<br>Kolding 6064<br>Denmark</h6>
|
||||
</div>
|
||||
</body>";
|
||||
|
||||
//string body = $@"Dear {senderName},<br><br>
|
||||
//Thank you for subscribing. We're thrilled to have you on board!<br><br>
|
||||
//To confirm your subscription, please click the following button:<br><br>
|
||||
//<a href=""{confirmationUrl}"" style=""display: inline-block; padding: 10px 20px; background-color: #28a745; color: #fff; text-decoration: none;"">Confirm Subscription</a><br><br>
|
||||
//If you have any questions or need assistance, feel free to contact us at help@seosoft.dk<br><br>
|
||||
|
||||
//<h5>
|
||||
// Søren Eggert Lundsteen Olsen<br>
|
||||
// Seosoft ApS
|
||||
//</h5>
|
||||
// <hr>
|
||||
// <h6>
|
||||
// Hovedgaden 3
|
||||
// Jordrup<br>
|
||||
// Kolding 6064<br>
|
||||
// Denmark
|
||||
//</6>
|
||||
// ";
|
||||
|
||||
var newEmail = new EmailToSend(email, subject, body);
|
||||
|
||||
|
|
@ -132,13 +192,54 @@ namespace Web.Controllers
|
|||
|
||||
// Send a "thank you" email to the user
|
||||
string subject = "Thank You for Confirming Your Subscription";
|
||||
string body = $"Dear {subscription.Name},<br><br>" +
|
||||
"Thank you for confirming your subscription. " +
|
||||
"You are now subscribed to our service.<br><br>" +
|
||||
string body = $@"<head>
|
||||
<meta charset=""UTF-8"">
|
||||
<meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
|
||||
<title>Email Confirmation</title>
|
||||
<style>
|
||||
body {{
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f9f9f9;
|
||||
}}
|
||||
.container {{
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
border: 0.5px solid #ccc;
|
||||
border-radius: 5px;
|
||||
background-color: #f9f9f9;
|
||||
}}
|
||||
h4, h5, h6 {{
|
||||
margin: 0;
|
||||
}}
|
||||
hr {{
|
||||
border: none;
|
||||
border-top: 1px solid #ccc;
|
||||
margin: 10px 0;
|
||||
}}
|
||||
a {{
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
}}
|
||||
a:hover {{
|
||||
text-decoration: underline;
|
||||
}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class=""container"">
|
||||
<h4>Dear {subscription.Name},</h4>
|
||||
<p>Thank you for confirming your subscription. You are now subscribed to our newsletter.</p>
|
||||
|
||||
"<h5>Søren Eggert Lundsteen Olsen<br>Seosoft ApS</h5>" +
|
||||
"<hr>" +
|
||||
"<h6>Hovedgaden 3<br>Jordrup<br>Kolding 6064<br>Denmark</h6>";
|
||||
<h5>Søren Eggert Lundsteen Olsen</h5>
|
||||
<h5><a href=""https://www.seosoft.dk/"" target=""_blank"">SeoSoft ApS</a></h5>
|
||||
<hr>
|
||||
<h6>Hovedgaden 3 Jordrup<br>Kolding 6064<br>Denmark</h6>
|
||||
</div>
|
||||
</body>";
|
||||
|
||||
|
||||
var thankYouEmail = new EmailToSend(subscription.Email, subject, body);
|
||||
|
|
@ -152,7 +253,7 @@ namespace Web.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
ViewBag.Message = "You have been unsubscribed from our service. Thank you!";
|
||||
ViewBag.Message = "You have been unsubscribed from our newsletter. Thank you!";
|
||||
return View(subscription);
|
||||
}
|
||||
}
|
||||
|
|
@ -182,17 +283,61 @@ namespace Web.Controllers
|
|||
await _context.SaveChangesAsync();
|
||||
|
||||
// Inform the user that the email has been unsubscribed
|
||||
ViewBag.Message = "You have been unsubscribed from our service. Thank you!";
|
||||
ViewBag.Message = "You have successfully unsubscribed from our newsletter. We're sorry to see you go";
|
||||
|
||||
// Optionally, send an email confirmation to the user
|
||||
string subject = "Unsubscribe Confirmation";
|
||||
string body = "You have successfully unsubscribed from our newsletter. We're sorry to see you go <br><br>" +
|
||||
string subject = "Unsubscription Confirmation";
|
||||
string body = $@"<head>
|
||||
<meta charset=""UTF-8"">
|
||||
<meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
|
||||
<title>Unsubscribe Confirmation</title>
|
||||
<style>
|
||||
body {{
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f9f9f9;
|
||||
}}
|
||||
.container {{
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
border: 0.5px solid #ccc;
|
||||
border-radius: 5px;
|
||||
background-color: #f9f9f9;
|
||||
}}
|
||||
h5, h6 {{
|
||||
margin: 0;
|
||||
}}
|
||||
hr {{
|
||||
border: none;
|
||||
border-top: 1px solid #ccc;
|
||||
margin: 10px 0;
|
||||
}}
|
||||
a {{
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
}}
|
||||
a:hover {{
|
||||
text-decoration: underline;
|
||||
}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class=""container"">
|
||||
<h3>Unsubscribe Confirmation</h3>
|
||||
<p>You have successfully unsubscribed from our newsletter. We're sorry to see you go.</p>
|
||||
<br>
|
||||
<h5><strong>Søren Eggert Lundsteen Olsen</strong></h5>
|
||||
<h5><a href=""https://www.seosoft.dk/"" target=""_blank"">SeoSoft ApS</a></h5>
|
||||
<hr>
|
||||
<h6>Hovedgaden 3<br>Jordrup<br>Kolding 6064<br>Denmark</h6>
|
||||
</div>
|
||||
</body>
|
||||
</html>";
|
||||
|
||||
|
||||
"<h5>Søren Eggert Lundsteen Olsen<br>Seosoft ApS</h5>"+
|
||||
"<hr>" +
|
||||
"<h6>Hovedgaden 3<br>Jordrup<br>Kolding 6064<br>Denmark</h6>";
|
||||
|
||||
var thankYouEmail = new EmailToSend(subscription.Email, subject, body);
|
||||
await _mailSerivces.SendConfirmationEmailAsync(thankYouEmail);
|
||||
|
||||
|
|
@ -208,7 +353,7 @@ namespace Web.Controllers
|
|||
else
|
||||
{
|
||||
// Inform the user that the unsubscription process couldn't be completed
|
||||
ViewBag.Message = "Your email does not exist in our subscription list. Please subscribe first.";
|
||||
ViewBag.Message = "You have been unsubscribed from our newsletter. subscribe first.";
|
||||
return View(subscription); // You can return a view to show an error message
|
||||
}
|
||||
}
|
||||
|
|
|
|||
18
Web/ViewModel/QuestionnaireVM/SendQuestionnaireViewModel.cs
Normal file
18
Web/ViewModel/QuestionnaireVM/SendQuestionnaireViewModel.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using NuGet.Protocol.Core.Types;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Web.ViewModel.QuestionnaireVM
|
||||
{
|
||||
public class SendQuestionnaireViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string? Name { get; set; }
|
||||
[Required]
|
||||
public string? Email { get; set; }
|
||||
|
||||
public int QuestionnaireId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
148
Web/Views/QuestionnaireResponse/DisplayQuestionnaire.cshtml
Normal file
148
Web/Views/QuestionnaireResponse/DisplayQuestionnaire.cshtml
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
@model Questionnaire
|
||||
@{
|
||||
ViewData["Title"] = "DisplayQuestionnaire";
|
||||
Layout = "~/Views/Shared/_QuestionnaireResponse.cshtml";
|
||||
}
|
||||
|
||||
<style>
|
||||
h5,h4{
|
||||
color: #b9b9b9 !important;
|
||||
}
|
||||
.rating {
|
||||
display: inline-flex;
|
||||
flex-direction: row-reverse; /* Set the direction to row-reverse */
|
||||
}
|
||||
|
||||
.rating input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rating label {
|
||||
cursor: pointer;
|
||||
font-size: 0; /* Hide the labels */
|
||||
}
|
||||
|
||||
.rating label:before {
|
||||
content: "☆";
|
||||
font-size: 25px; /* Set the font size of the stars */
|
||||
}
|
||||
|
||||
.rating input:checked ~ label:before {
|
||||
content: "★";
|
||||
color: orange;
|
||||
}
|
||||
|
||||
.slider-value {
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin-top: -20px; /* Adjust the margin to position the value */
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<div class="d-flex flex-column" id="BannerBackground">
|
||||
|
||||
|
||||
<section class="hero text-white">
|
||||
<div class="container text-white mt-5">
|
||||
<h4><strong>@Html.Raw(Model.Description)</strong> </h4>
|
||||
@{
|
||||
int questionNumber = 1; // Counter for question numbers, starting from 1
|
||||
}
|
||||
|
||||
<form method="post" action="@Url.Action("Submit", "Questionnaire", new { id = Model.Id })">
|
||||
<div class="container">
|
||||
@foreach (var question in Model.Questions)
|
||||
{
|
||||
<h5>@questionNumber. @question.Text</h5> <!-- Display question number -->
|
||||
<div>
|
||||
@if (question.Type == QuestionType.Multiple_choice)
|
||||
{
|
||||
@foreach (var answer in question.Answers)
|
||||
{
|
||||
<label>
|
||||
<input type="checkbox" name="answers[@question.Id]" value="@answer.Id" class="form-check-input" /> @answer.Text
|
||||
</label>
|
||||
<br />
|
||||
}
|
||||
}
|
||||
else if (question.Type == QuestionType.Ranking)
|
||||
{
|
||||
<select name="answers[@question.Id]" class="form-control">
|
||||
<option value="">Select Rank</option>
|
||||
@for (int i = 1; i <= question.Answers.Count; i++)
|
||||
{
|
||||
<option value="@i">@i</option>
|
||||
}
|
||||
</select>
|
||||
}
|
||||
else if (question.Type == QuestionType.TrueFalse)
|
||||
{
|
||||
<label>
|
||||
<input type="radio" name="answers[@question.Id]" value="true" class="form-check-input" /> True
|
||||
</label>
|
||||
<br />
|
||||
<label>
|
||||
<input type="radio" name="answers[@question.Id]" value="false" class="form-check-input" /> False
|
||||
</label>
|
||||
}
|
||||
else if (question.Type == QuestionType.Rating)
|
||||
{
|
||||
<div class="rating">
|
||||
@for (int i = 1; i <= question.Answers.Count; i++)
|
||||
{
|
||||
<input type="radio" id="star@(i)" name="answers[@question.Id]" value="@i" class="form-check-input" />
|
||||
<label for="star@(i)" title="@i">☆</label>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else if (question.Type == QuestionType.Text)
|
||||
{
|
||||
<input type="text" name="answers[@question.Id]" class="form-control" />
|
||||
}
|
||||
else if (question.Type == QuestionType.Slider)
|
||||
{
|
||||
<input type="range" name="answers[@question.Id]" min="0" max="100" value="0" class="slider" oninput="updateSliderValue(this.value, 'sliderValue_@question.Id')" /> <!-- Set initial value to 0 -->
|
||||
<span id="sliderValue_@question.Id" class="slider-value">0</span> <!-- Display the slider value -->
|
||||
}
|
||||
<!-- Add handling for other question types as needed -->
|
||||
</div>
|
||||
<hr />
|
||||
@@questionNumber
|
||||
++; // Increment question number after displaying
|
||||
}
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@section Scripts {
|
||||
|
||||
|
||||
@{
|
||||
<partial name="_ValidationScriptsPartial" />
|
||||
}
|
||||
|
||||
<script>
|
||||
function updateSliderValue(value, targetId) {
|
||||
// Increase value by 10
|
||||
value = parseInt(value) + 10;
|
||||
document.getElementById(targetId).innerText = value;
|
||||
}
|
||||
</script>
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
<div class="container py-4">
|
||||
<div id="rowSection">
|
||||
<div class="col-lg-6" id="box">
|
||||
<p class="display-6 font-weight-bold" id="BtnColor">@Model.Title.ToUpper()</p>
|
||||
<h3 class=" font-weight-bold" id="BtnColor">@Model.Title.ToUpper()</h3>
|
||||
@* <p class="fst-italic text-muted">@Html.Raw(Model.Content) <a class="text-primary" href="@Model.Sitecopyright" target="_blank">SeoSoft</a></p> *@
|
||||
but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
||||
|
||||
|
|
@ -23,8 +23,6 @@
|
|||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
<!-- FOOTER -->
|
||||
<footer class="w-100 py-4 flex-shrink-0">
|
||||
<div class="container">
|
||||
|
|
@ -64,19 +62,19 @@
|
|||
<div class="row d-flex justify-content-around">
|
||||
|
||||
<div class="col-lg-2 col-md-3">
|
||||
<span class=" muted">Designed by @Model.CreatedBy</span>
|
||||
<span class="text-muted">Designed by @Model.CreatedBy</span>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-3">
|
||||
<span class=" muted">Update by @Model.UpdatedBy</span>
|
||||
<span class="text-muted">Update by @Model.UpdatedBy</span>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-3">
|
||||
<span class=" muted">Updated @Model.LastUpdated.ToShortDateString()</span>
|
||||
<span class=" text-muted">Updated @Model.LastUpdated.ToShortDateString()</span>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-3">
|
||||
<span class=" muted">Owner @Model.Owner</span>
|
||||
<span class=" text-muted">Owner @Model.Owner</span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
54
Web/Views/Shared/_QuestionnaireResponse.cshtml
Normal file
54
Web/Views/Shared/_QuestionnaireResponse.cshtml
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - Web</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/Web.styles.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light shadow-lg">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Online survey</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon text-white"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
|
||||
|
||||
</ul>
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a href="#" class="btn btn-sm " id="BannerButon"> Sign in <i class="bi bi-person-check-fill"></i></a> |
|
||||
<a href="#" class="btn btn-sm" id="BannerButon"> Sign up <i class="bi bi-person-fill-add"></i></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main role="main">
|
||||
|
||||
@RenderBody()
|
||||
</main>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -14,14 +14,14 @@
|
|||
</div> *@
|
||||
<div id="rowSectionBanner">
|
||||
|
||||
<div class="col-lg-6" id="boxBanner">
|
||||
<h1 class="display-6 font-weight-bold" id="BtnColor">Hey @Model?.Name</h1>
|
||||
<div class="col-lg-7" id="boxBanner">
|
||||
<h3 class="font-weight-bold" id="BtnColor">Hey @Model?.Name</h3>
|
||||
|
||||
@* <p class="fst-italic text-muted">@Html.Raw(Model.Content) <a class="text-primary" href="@Model.Sitecopyright" target="_blank">SeoSoft</a></p> *@
|
||||
<p class="text-white">@ViewBag.Message</p>
|
||||
<h5 class="text-white">@ViewBag.Message</h5>
|
||||
<a href="/home" class="btn btn-sm mt-1" id="BannerButon"><i class="bi bi-arrow-left-square-fill"></i> Back to home </a>
|
||||
</div>
|
||||
<div class="col-lg-6" id="boxBanner">
|
||||
<div class="col-lg-5" id="boxBanner">
|
||||
<script src="https://unpkg.com/@@dotlottie/player-component@latest/dist/dotlottie-player.mjs" type="module"></script>
|
||||
<dotlottie-player src="https://lottie.host/543409f4-933c-456f-923c-f936be0d0da6/UxmKdWjkuD.json" class="img-fluid" speed="1" style="width: auto; height: auto;" direction="1" playMode="normal" autoplay></dotlottie-player>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@
|
|||
</div> *@
|
||||
<div id="rowSectionBanner">
|
||||
|
||||
<div class="col-lg-6" id="boxBanner">
|
||||
<h1 class="display-6 font-weight-bold" id="BtnColor">Hey @Model?.Name</h1>
|
||||
<div class="col-lg-7" id="boxBanner">
|
||||
<h3 class="font-weight-bold" id="BtnColor">Hey @Model?.Name</h3>
|
||||
|
||||
@* <p class="fst-italic text-muted">@Html.Raw(Model.Content) <a class="text-primary" href="@Model.Sitecopyright" target="_blank">SeoSoft</a></p> *@
|
||||
<p class="text-white">@ViewBag.Message</p>
|
||||
<h5 class="text-white">@ViewBag.Message</h5>
|
||||
<a href="/home" class="btn btn-sm mt-1" id="BannerButon"><i class="bi bi-arrow-left-square-fill"></i> Back to home </a>
|
||||
</div>
|
||||
<div class="col-lg-6" id="boxBanner">
|
||||
<div class="col-lg-5" id="boxBanner">
|
||||
<script src="https://unpkg.com/@@dotlottie/player-component@latest/dist/dotlottie-player.mjs" type="module"></script>
|
||||
<dotlottie-player src="https://lottie.host/543409f4-933c-456f-923c-f936be0d0da6/UxmKdWjkuD.json" class="img-fluid" speed="1" style="width: auto; height: auto;" direction="1" playMode="normal" autoplay></dotlottie-player>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -14,14 +14,13 @@
|
|||
"From": "mr.qais.yousuf@gmail.com",
|
||||
"ApplicationName": "Online Survey",
|
||||
"ConfirmEmailPath": "Subscription/Confirmation",
|
||||
"unsubscribePath": "Subscription/UnsubscribeConfirmation"
|
||||
"unsubscribePath": "Subscription/UnsubscribeConfirmation",
|
||||
"Questionnaire": "QuestionnaireResponse/DisplayQuestionnaire"
|
||||
|
||||
},
|
||||
"MailJet": {
|
||||
"ApiKey": "f545eee3a4743464b9d25fb9c5ab3f6c",
|
||||
"SecretKey": "9fa430ef00873fdefe333fdc40ee3f8f"
|
||||
}
|
||||
//"OpenAI": {
|
||||
// "ApiKey": "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"
|
||||
//}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ footer {
|
|||
}
|
||||
|
||||
#LinkColor {
|
||||
color: #6c757d !important;
|
||||
color: #a8afb5 !important;
|
||||
}
|
||||
|
||||
body, html {
|
||||
|
|
@ -11567,9 +11567,9 @@ body, html {
|
|||
color: #212529 !important;
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
color: #6c757d !important;
|
||||
}
|
||||
.text-muted {
|
||||
color: #a8afb5 !important;
|
||||
}
|
||||
|
||||
.text-black-50 {
|
||||
color: rgba(0, 0, 0, 0.5) !important;
|
||||
|
|
@ -11817,9 +11817,10 @@ body, html {
|
|||
}
|
||||
|
||||
#sidebar.active {
|
||||
min-width: 80px;
|
||||
min-width: 100px;
|
||||
max-width: 80px;
|
||||
text-align: center;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
#sidebar.active ul.components li {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue