Skip to content

Commit

Permalink
Issue #295 reduce spam (#296)
Browse files Browse the repository at this point in the history
* Refactor contact form to use mailto

* Remove ContactPage HttpPost due to form using mailto

* Remove contact page model
  • Loading branch information
JoeProgrammer88 authored Feb 14, 2024
1 parent 10ec9d9 commit 7c4066b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 65 deletions.
16 changes: 0 additions & 16 deletions PC2/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,6 @@ public IActionResult ContactPage()
{
return View();
}
[HttpPost]
public async Task<IActionResult> ContactPage(ContactPageModel contactPageModel)
{
if (ModelState.IsValid)
{
Response result = await _emailSender.SendEmailAsync(contactPageModel.Name, contactPageModel.Email, contactPageModel.Phone, contactPageModel.Subject, contactPageModel.Message);
ViewData["EmailSent"] = result.IsSuccessStatusCode;
if (result.IsSuccessStatusCode)
{
// Clear the data from the model
ModelState.Clear();
return View(new ContactPageModel());
}
}
return View();
}

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
Expand Down
29 changes: 0 additions & 29 deletions PC2/Models/ContactPageModel.cs

This file was deleted.

28 changes: 8 additions & 20 deletions PC2/Views/Home/ContactPage.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@model ContactPageModel
@inject IConfiguration Configuration
@{
ViewData["Title"] = "Contact Us";
}
Expand Down Expand Up @@ -34,43 +34,31 @@
<p>Suite A</p>
<p>Tacoma, WA 98418</p>
<br />
<a href = "mailto: [email protected]"><p>info@pc2online.org</p></a>
<a href = "mailto:[email protected]"><p>info@pc2online.org</p></a>
<a href="tel: +2535640707"><p>253.564.0707</p></a>
<a href="tel: +8773354657"><p>877-DD-LINKS</p></a>
<p>253.564.0702 (fax)</p>
</div>

<div class="col-7">
<form asp-action="ContactPage" method="post">
<form action="mailto:@Configuration["PC2Email"]">
<div class="row">
<div class="col">
<div class="form-group">
<input asp-for="Name" class="form-control" placeholder="Name" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<br />
<div class="form-group">
<input asp-for="Email" class="form-control" placeholder="Email"/>
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<br />
<div class="form-group">
<input asp-for="Phone" class="form-control" placeholder="Phone"/>
<span asp-validation-for="Phone" class="text-danger"></span>
<input type="email" required name="email" class="form-control" placeholder="Your Email"/>
</div>
<br />
<div class="mb-3">
<input asp-for="Subject" class="form-control" placeholder="Subject"/>
<span asp-validation-for="Subject" class="text-danger"></span>
<input name="subject" type="text" required class="form-control" placeholder="Subject"/>
</div>
<br />
</div>
<div class="col">
<div class="mb-3">
<textarea asp-for="Message" class="form-control" rows="6" placeholder="Message"></textarea>
<span asp-validation-for="Message" class="text-danger"></span>
<textarea name="body" required class="form-control" rows="6" cols="30" placeholder="Enter your name, any additional contact info, and message here"></textarea>
</div>
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
<button type="submit" class="btn btn-primary me-md-2">Send</button>
<input type="submit" class="btn btn-primary me-md-2" value="Send" />
</div>
</div>
</div>
Expand Down

0 comments on commit 7c4066b

Please sign in to comment.