blob: b99698925a4fe0edef63029d7ea2854e8d7f9acc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Microsoft.AspNet.Identity;
using Project_Unite.Models;
namespace Project_Unite.Controllers
{
public class HomeController : Controller
{
public ActionResult SendFeedback()
{
var sfm = new SendFeedbackViewModel();
if(Request.IsAuthenticated)
{
var db = new ApplicationDbContext();
var user = db.Users.FirstOrDefault(x => x.UserName == User.Identity.Name);
sfm.Name = (string.IsNullOrWhiteSpace(user.FullName)) ? user.DisplayName : user.FullName;
sfm.Email = user.Email;
}
return View(sfm);
}
public ActionResult AboutUnite()
{
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult SendFeedback(SendFeedbackViewModel model)
{
if (!ModelState.IsValid)
return View(model);
var db = new ApplicationDbContext();
var siteconfig = db.Configs.FirstOrDefault();
var mailsender = new EmailService();
var message = new IdentityMessage
{
Destination = siteconfig.FeedbackEmail,
Subject = "[Feedback] " + model.Name,
Body = $@"<h1>Project: Unite Feedback</h1>
<dl>
<dt>From:</dt>
<dd>{model.Name} [{model.Email}]</dd>
<dt>Type:</dt>
<dd>{model.FeedbackType}</dd>
</dl>
<hr/>
{ACL.MarkdownRaw(model.Body)}"
};
mailsender.SendAsync(message);
return RedirectToAction("Index");
}
public ActionResult AccessDenied()
{
return View();
}
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
public ActionResult Discord()
{
return View();
}
[HttpPost]
public ActionResult Search(string query)
{
var result = new SearchResult();
query = query.ToLower();
var db = new ApplicationDbContext();
result.Downloads = db.Downloads.Where(x => x.Name.ToLower().Contains(query) || x.Changelog.ToLower().Contains(query));
result.ForumTopics = db.ForumTopics.Where(x => x.Subject.ToLower().Contains(query));
result.Skins = db.Skins.Where(x => x.Name.ToLower().Contains(query) || x.ShortDescription.ToLower().Contains(query) || x.FullDescription.ToLower().Contains(query));
result.Users = db.Users.Where(x => x.DisplayName.ToLower().Contains(query) || x.Bio.ToLower().Contains(query) || x.Interests.ToLower().Contains(query) || x.Hobbies.ToLower().Contains(query));
result.WikiPages = db.WikiPages.Where(x => x.Name.ToLower().Contains(query) || x.Contents.ToLower().Contains(query));
//Holy crap that search was... long.
return View(result);
}
}
}
|