groups (formerly legions) index

This commit is contained in:
Michael 2017-05-07 09:19:55 -04:00
parent 0cdba811a6
commit 0ae47a126b
5 changed files with 103 additions and 0 deletions

View file

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Project_Unite.Models;
namespace Project_Unite.Controllers
{
public class GroupsController : Controller
{
// GET: Groups
public ActionResult Index()
{
var db = new ApplicationDbContext();
return View(db.Groups);
}
}
}

View file

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Project_Unite.Models
{
public class Group
{
public string Id { get; set; }
public string Name { get; set; }
public int Publicity { get; set; }
public string BannerColorHex { get; set; }
public string Description { get; set; }
public string ShortName { get; set; }
public double RawReputation { get; set; }
public int Reputation
{
get
{
return ((int)Math.Round(RawReputation));
}
}
}
}

View file

@ -30,6 +30,8 @@ public class UploadImageViewModel
// You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
public class ApplicationUser : IdentityUser
{
public string GroupId { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
@ -252,6 +254,7 @@ public static ApplicationDbContext Create()
public DbSet<Story> Stories { get; set; }
public DbSet<View> Views { get; set; }
public DbSet<OAuthToken> OAuthTokens { get; set; }
public DbSet<Group> Groups { get; set; }
}
public class OAuthToken

View file

@ -256,6 +256,7 @@
<Compile Include="Controllers\DeveloperController.cs" />
<Compile Include="Controllers\DownloadController.cs" />
<Compile Include="Controllers\ForumController.cs" />
<Compile Include="Controllers\GroupsController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\LegalController.cs" />
<Compile Include="Controllers\ManageController.cs" />
@ -441,6 +442,7 @@
<Compile Include="Models\Download.cs" />
<Compile Include="Models\ForumCategory.cs" />
<Compile Include="Models\ForumViewModels.cs" />
<Compile Include="Models\Group.cs" />
<Compile Include="Models\HomeViewModel.cs" />
<Compile Include="Models\IdentityModels.cs" />
<Compile Include="Models\ManageViewModels.cs" />
@ -587,6 +589,7 @@
<Content Include="Views\Bugs\PostBug.cshtml" />
<Content Include="Views\Stats\Pong.cshtml" />
<Content Include="Views\Stats\Codepoints.cshtml" />
<Content Include="Views\Groups\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />

View file

@ -0,0 +1,50 @@
@model IEnumerable<Project_Unite.Models.Group>
@{
ViewBag.Title = "Groups";
}
<h2>Groups</h2>
<p>Groups, formerly called <strong>Legions</strong>, are a way of grouping the community into different, well, groups, with their own tasks and goals.</p>
<p>You can join one of the in-game groups from your Digital Society Control Centre, or you can join one of the many user-created groups here.</p>
<table class="table">
<tr>
<th style="width:65%">Group</th>
<th>Users</th>
<th>Actions</th>
</tr>
@if(Model.Count() > 0)
{
foreach(var group in Model)
{
if (group.Publicity < 2)
{
<tr>
<td>
@Html.ActionLink(group.Name, "ViewGroup", "Groups", new { id = group.Id }, null) <br/>
<p><strong>[@group.ShortName]</strong> &bull; @group.Publicity.ToString()</p>
</td>
<td>
@group.Users.Count()
</td>
<td>
@Html.ActionLink("Join", "JoinGroup", "Groups", new { id=@group.Id}, new { @class="btn btn-default"})
</td>
</tr>
}
}
}
else
{
<tr>
<td>No groups found! Be the first to create one!</td>
<td></td>
<td></td>
</tr>
}
</table>