refactor!: merge contact into one form (WEB-2)

This commit is contained in:
Oliver Booth 2023-09-25 19:55:34 +01:00
parent bcb2e9292a
commit f912fa580d
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5
9 changed files with 35 additions and 343 deletions

View File

@ -31,35 +31,8 @@ public class ContactController : Controller
return RedirectToPage("/Contact/Index"); return RedirectToPage("/Contact/Index");
} }
[HttpPost("privacy-policy")]
public async Task<IActionResult> HandlePrivacyPolicy()
{
if (!Request.HasFormContentType)
{
return RedirectToPage("/Contact/Privacy");
}
IFormCollection form = Request.Form;
StringValues name = form["name"];
StringValues email = form["email"];
StringValues subject = form["subject"];
StringValues message = form["message"];
StringValues privacyPolicy = form["privacy-policy"];
await using SmtpSender sender = CreateSender();
await sender.WriteEmail
.To("Oliver Booth", _destination.GetValue<string>("PrivacyPolicy"))
.From(name, email)
.Subject($"[{privacyPolicy}] {subject}")
.BodyHtml(message)
.SendAsync();
TempData["Success"] = true;
return RedirectToPage("/Contact/Result");
}
[HttpPost("other")] [HttpPost("other")]
public async Task<IActionResult> HandleMiscellaneous() public async Task<IActionResult> HandleForm()
{ {
if (!Request.HasFormContentType) if (!Request.HasFormContentType)
{ {
@ -74,10 +47,10 @@ public class ContactController : Controller
await using SmtpSender sender = CreateSender(); await using SmtpSender sender = CreateSender();
await sender.WriteEmail await sender.WriteEmail
.To("Oliver Booth", _destination.GetValue<string>("Other")) .To("Oliver Booth", _destination.Get<string>())
.From(name, email) .From(name, email)
.Subject(subject) .Subject($"[Contact via Website] {subject}")
.BodyHtml(message) .BodyText(message)
.SendAsync(); .SendAsync();
TempData["Success"] = true; TempData["Success"] = true;

View File

@ -4,13 +4,34 @@
} }
<h1 class="display-4">Contact</h1> <h1 class="display-4">Contact</h1>
<p class="lead">What would you like to talk about?</p> <p>
<ul class="contact-reasons"> Thanks for getting in touch! While I do my best to read to all inquiries, I cannot guarantee that I will be able to
<li><a asp-page="JobOpportunity">💼 Job opportunity / collaboration</a></li> respond to your message. Nevertheless, I appreciate you taking the time to reach out to me and I will respond if I
<li><a asp-page="/Donate">☕ Donate money for coffee</a></li> can.
<li><a asp-page="ProjectIdea">💡 Project idea</a></li> </p>
<li><a asp-page="TechnicalHelp">💬️ Technical help and code review</a></li>
<li><a asp-page="OpenSource">🌍 Open source contribution</a></li> <form method="post" asp-controller="Contact" asp-action="HandleForm">
<li><a asp-page="Privacy">🔒 Privacy policy concerns</a></li> <input type="hidden" name="contact-type" value="other">
<li><a asp-page="Other">❓ Misc / general inquiry</a></li>
</ul> <div class="form-group" style="margin-top: 10px;">
<label for="name">Your Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Who are you?" required>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="email">Your Email Address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="How can I reach you?" required>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="subject">Subject</label>
<input type="text" class="form-control" id="subject" name="subject" placeholder="What's the gist?" maxlength="100" required>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="message">Message</label>
<textarea class="form-control" id="message" name="message" rows="5" required placeholder="What's on your mind?"></textarea>
</div>
<button class="btn btn-primary" style="margin-top: 10px;">Submit</button>
</form>

View File

@ -1,56 +0,0 @@
@page "/contact/job-opportunity"
@{
ViewData["Title"] = "Contact";
}
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a asp-page="Index">Contact</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Job Opportunity</li>
</ol>
</nav>
<p>
I am always open to hearing about future opportunities. If you have a position you think I could be a good fit for,
please feel free to contact me using the form below. At this time, I am only open to positions based in South East
Wales or that are 100% remote.
</p>
<p>I look forward to hearing from you!</p>
<form method="post">
<input type="hidden" name="contact-type" value="job-opportunity">
<div class="form-group" style="margin-top: 10px;">
<label for="name">Your Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Who are you?" required>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="email">Your Email Address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="How can I reach you?" required>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="company-name">Company Name</label>
<input type="text" class="form-control" id="company-name" name="company-name" placeholder="Who do you represent?" required>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="position-title">Job Position Title</label>
<input type="text" class="form-control" id="position-title" name="position-title" placeholder="e.g. C# Software Developer" required>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="position-description">Description</label>
<textarea class="form-control" id="position-description" name="position-description" rows="5" required placeholder="Explain the duties of the role and a bit about the company."></textarea>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="starting-salary">Starting Salary</label>
<input type="text" class="form-control" id="starting-salary" name="starting-salary" placeholder="e.g. £30,000" required>
</div>
<button type="submit" class="btn btn-primary" style="margin-top: 10px;">Submit</button>
</form>

View File

@ -1,35 +0,0 @@
@page "/contact/open-source"
@{
ViewData["Title"] = "Contact";
}
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a asp-page="Index">Contact</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Open Source Contribution</li>
</ol>
</nav>
<p>
Thank you for taking the time to consider contributing to one of my open source projects. I appreciate any and all
contributions that I receive. You do not need to contact me to do so, just submit a pull request on GitHub and I
will review it as soon as I can!
</p>
<p>
Below is a <mark>non-exhaustive</mark> list of the repositories that are currently active. This list is subject
to change at any time, but may not be up-to-date. For a better gauge of what I am currently working on, please
visit my <a href="https://github.com/oliverbooth">GitHub profile</a>. If you would like to contribute to a project
that is not in active development, I would recommend that you fork the repository and continue development on your
own as unfortunately I have no timeline as to when I will start such projects back up again.
</p>
<ul>
<li>
<a href="https://github.com/oliverbooth/X10D">X10D</a>
</li>
<li>
<a href="https://github.com/BrackeysBot/">BrackeysBot</a>
</li>
</ul>

View File

@ -1,45 +0,0 @@
@page
@{
ViewData["Title"] = "Contact";
}
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a asp-page="Index">Contact</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Other</li>
</ol>
</nav>
<p>
Thanks for getting in touch! While I do my best to read to all inquiries, I cannot guarantee that I will be able to
respond to your message. Nevertheless, I appreciate you taking the time to reach out to me and I will respond if I
can.
</p>
<form method="post" asp-controller="Contact" asp-action="HandleMiscellaneous">
<input type="hidden" name="contact-type" value="other">
<div class="form-group" style="margin-top: 10px;">
<label for="name">Your Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Who are you?" required>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="email">Your Email Address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="How can I reach you?" required>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="subject">Subject</label>
<input type="text" class="form-control" id="subject" name="subject" placeholder="What's the gist?" maxlength="100" required>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="message">Message</label>
<textarea class="form-control" id="message" name="message" rows="5" required placeholder="What's on your mind?"></textarea>
</div>
<button class="btn btn-primary" style="margin-top: 10px;">Submit</button>
</form>

View File

@ -1,54 +0,0 @@
@page "/contact/privacy/{which?}"
@model OliverBooth.Pages.Contact.Privacy
@{
ViewData["Title"] = "Contact";
}
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a asp-page="Index">Contact</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Privacy Policy Concerns</li>
</ol>
</nav>
<p>
Thank you for getting in touch. I take your privacy very seriously and will do my best to address any concerns you may have.
Please outline your concerns in the form below, and I will get back to you as soon as possible.
</p>
<form method="post" asp-controller="Contact" asp-action="HandlePrivacyPolicy">
<input type="hidden" name="contact-type" value="privacy-policy">
<div class="form-group" style="margin-top: 10px;">
<label for="name">Your Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Who are you?">
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="email">Your Email Address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="How can I reach you?">
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="privacy-policy">Privacy Policy</label>
<select name="privacy-policy" class="form-control" id="privacy-policy">
<option value="website" selected="@(Model.Which == "website")">This website's policy</option>
<option value="google-play" selected="@(Model.Which == "google-play")">Google Play policy</option>
<option value="five-oclock-somewhere" selected="@(Model.Which == "five-oclock-somewhere")">It's 5 O'Clock Somewhere policy</option>
</select>
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="subject">Subject</label>
<input type="text" class="form-control" id="subject" name="subject" placeholder="Describe your concerns here in a few words" maxlength="100">
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="message">Description</label>
<textarea class="form-control" id="message" name="message" rows="5" required placeholder="Go into detail about the nature of your concerns."></textarea>
</div>
<button type="submit" class="btn btn-primary" style="margin-top: 10px;">Submit</button>
</form>

View File

@ -1,17 +0,0 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace OliverBooth.Pages.Contact;
public class Privacy : PageModel
{
public string Which { get; private set; } = "website";
public void OnGet(string? which = "website")
{
Which = which ?? "website";
}
public void SubmitForm()
{
}
}

View File

@ -1,70 +0,0 @@
@page "/contact/project-idea"
@{
ViewData["Title"] = "Contact";
}
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a asp-page="Index">Contact</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Project Idea</li>
</ol>
</nav>
<p>
If you have any ideas for a project that you'd like to see me work on, please feel free to contact me using the
form below. I'm always looking for something new to work on, and I'm open to suggestions!
</p>
<div class="alert alert-warning">
<p>
Please note that by submitting an idea through the form on this page, you acknowledge and agree that any
intellectual property rights associated with the idea, including but not limited to copyright, patent, or any
other proprietary rights, shall be immediately and irrevocably transferred to me. You understand that this
transfer of intellectual property rights grants me the unrestricted and exclusive right to use, modify,
reproduce, distribute, disclose, or otherwise exploit the idea for any purpose, without the obligation to
provide credit or compensation to you. This includes the right to file for intellectual property protection or
pursue commercial opportunities derived from the idea. By submitting the idea, you further confirm that it is
your original work and does not infringe upon the rights of any third party.
</p>
<p>
<strong>
If this is not something you want, and you'd like to collaborate, please
<span style="text-decoration: underline">do not</span> use this form, instead, please use
<a asp-page="JobOpportunity">this one</a>.
</strong>
</p>
</div>
<form method="post">
<input type="hidden" name="contact-type" value="project-idea">
<div class="form-group" style="margin-top: 10px;">
<label for="name">Your Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Who are you?">
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="email">Your Email Address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="How can I reach you, if I need to?">
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="project-title">Project Title (If Applicable)</label>
<input type="text" class="form-control" id="project-title" name="project-title" placeholder="Title">
</div>
<div class="form-group" style="margin-top: 10px;">
<label for="project-description">Project Description</label>
<textarea class="form-control" id="project-description" name="project-description" rows="5" required placeholder="Explain the idea here"></textarea>
</div>
<div class="form-check" style="margin-top: 10px;">
<input class="form-check-input" type="checkbox" id="agreement-checkbox" name="agreement-checkbox" required>
<label class="form-check-label" for="agreement-checkbox">
I acknowledge and agree to the transfer of intellectual property rights as described above.
</label>
</div>
<button type="submit" class="btn btn-primary" style="margin-top: 10px;">Submit</button>
</form>

View File

@ -1,25 +0,0 @@
@page "/contact/technical-help"
@{
ViewData["Title"] = "Contact";
}
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a asp-page="Index">Contact</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Technical Help</li>
</ol>
</nav>
<p>
I'm sorry, but do I not offer help or advice regarding development of any kind outside of my website, and Discord
servers of which I'm a member. I'm most active in the <a href="https://discord.gg/brackeys">Brackeys Community</a>
Discord server, where I'm an Admin, but this does not give you permission to demand help from me on your schedule.
If you have a question, please ask in the appropriate channel in that server. If you ping or DM me, I will ignore
you.
</p>
<p>
I do not offer services to build or repair desktops, laptops, mobiles, or tablets, outside of my family and close
friends.
</p>