mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-23 01:32:16 +00:00
Profile work.
This commit is contained in:
parent
8330fbc5cb
commit
0f2629f060
5 changed files with 98 additions and 1 deletions
29
Project-Unite/Controllers/ProfilesController.cs
Normal file
29
Project-Unite/Controllers/ProfilesController.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using Project_Unite.Models;
|
||||||
|
|
||||||
|
namespace Project_Unite.Controllers
|
||||||
|
{
|
||||||
|
[Authorize]
|
||||||
|
public class ProfilesController : Controller
|
||||||
|
{
|
||||||
|
// GET: Profiles
|
||||||
|
public ActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult ViewProfile(string id)
|
||||||
|
{
|
||||||
|
var db = new ApplicationDbContext();
|
||||||
|
var user = db.Users.FirstOrDefault(x => x.DisplayName == id);
|
||||||
|
if (user == null)
|
||||||
|
return new HttpStatusCodeResult(404);
|
||||||
|
|
||||||
|
return View(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Data.Entity;
|
using System.Data.Entity;
|
||||||
using System.Data.Entity.Infrastructure;
|
using System.Data.Entity.Infrastructure;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -131,4 +132,34 @@ public static ApplicationDbContext Create()
|
||||||
public DbSet<ForumPost> ForumPosts { get; set; }
|
public DbSet<ForumPost> ForumPosts { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class UserPost
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string UserId { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(1000, ErrorMessage ="Your post can't have more than 1000 characters.")]
|
||||||
|
[AllowHtml]
|
||||||
|
[MinLength(20, ErrorMessage ="To prevent spam, you must have at least 20 characters in your post.")]
|
||||||
|
public string PostContents { get; set; }
|
||||||
|
|
||||||
|
public DateTime PostedAt { get; set; }
|
||||||
|
|
||||||
|
public Like[] Likes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new ApplicationDbContext().Likes.Where(l => l.Topic == this.Id).Where(x => x.IsDislike == false).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Like[] Dislikes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new ApplicationDbContext().Likes.Where(l => l.Topic == this.Id).Where(x => x.IsDislike == true).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -232,6 +232,7 @@
|
||||||
<Compile Include="Controllers\LegalController.cs" />
|
<Compile Include="Controllers\LegalController.cs" />
|
||||||
<Compile Include="Controllers\ManageController.cs" />
|
<Compile Include="Controllers\ManageController.cs" />
|
||||||
<Compile Include="Controllers\ModeratorController.cs" />
|
<Compile Include="Controllers\ModeratorController.cs" />
|
||||||
|
<Compile Include="Controllers\ProfilesController.cs" />
|
||||||
<Compile Include="Global.asax.cs">
|
<Compile Include="Global.asax.cs">
|
||||||
<DependentUpon>Global.asax</DependentUpon>
|
<DependentUpon>Global.asax</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -505,6 +506,8 @@
|
||||||
<Content Include="Views\Shared\_PostModerationBar.cshtml" />
|
<Content Include="Views\Shared\_PostModerationBar.cshtml" />
|
||||||
<Content Include="Views\Forum\EditPost.cshtml" />
|
<Content Include="Views\Forum\EditPost.cshtml" />
|
||||||
<Content Include="Views\Legal\TOS.cshtml" />
|
<Content Include="Views\Legal\TOS.cshtml" />
|
||||||
|
<Content Include="Views\Profiles\ViewProfile.cshtml" />
|
||||||
|
<Content Include="Views\Profile\ViewProfile.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="App_Data\" />
|
<Folder Include="App_Data\" />
|
||||||
|
|
27
Project-Unite/Views/Profiles/ViewProfile.cshtml
Normal file
27
Project-Unite/Views/Profiles/ViewProfile.cshtml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
@model Project_Unite.Models.ApplicationUser
|
||||||
|
@{
|
||||||
|
ViewBag.Title = Model.DisplayName;
|
||||||
|
ViewBag.Banner = Model.BannerUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<h3>
|
||||||
|
<img src="@Model.AvatarUrl" width="64" height="64" /> @if (string.IsNullOrWhiteSpace(Model.FullName))
|
||||||
|
{ <strong> @Model.DisplayName </strong>}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<strong>@Model.FullName</strong> <em>(@Model.DisplayName)</em>}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-4">
|
||||||
|
<h4>User stats</h4>
|
||||||
|
<ul>
|
||||||
|
<li><strong>@Model.Codepoints</strong> Codepoints</li>
|
||||||
|
<li><strong>Joined at: </strong>@Model.JoinedAt</li>
|
||||||
|
<li><strong>Posts: </strong>@Model.PostCount</li>
|
||||||
|
<li><strong>Topics: </strong>@Model.TopicCount</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -12,7 +12,14 @@
|
||||||
@Scripts.Render("~/bundles/modernizr")
|
@Scripts.Render("~/bundles/modernizr")
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
@{
|
||||||
|
string style = "";
|
||||||
|
if(ViewBag.Model != null)
|
||||||
|
{
|
||||||
|
style = "background-image: url(\"" + ViewBag.Model + "\") cover;";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<body style="@style">
|
||||||
@Scripts.Render("~/Scripts/highlight.js")
|
@Scripts.Render("~/Scripts/highlight.js")
|
||||||
<div class="navbar navbar-default navbar-fixed-top">
|
<div class="navbar navbar-default navbar-fixed-top">
|
||||||
<div> <!--Let's just add some padding there so the page doesn't look fucked.-->
|
<div> <!--Let's just add some padding there so the page doesn't look fucked.-->
|
||||||
|
|
Loading…
Reference in a new issue