From 0ae47a126b1fb37ecbc80ecddd34a892fb6fd3b2 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 7 May 2017 09:19:55 -0400 Subject: groups (formerly legions) index --- Project-Unite/Controllers/GroupsController.cs | 19 ++++++++++ Project-Unite/Models/Group.cs | 28 +++++++++++++++ Project-Unite/Models/IdentityModels.cs | 3 ++ Project-Unite/Project-Unite.csproj | 3 ++ Project-Unite/Views/Groups/Index.cshtml | 50 +++++++++++++++++++++++++++ 5 files changed, 103 insertions(+) create mode 100644 Project-Unite/Controllers/GroupsController.cs create mode 100644 Project-Unite/Models/Group.cs create mode 100644 Project-Unite/Views/Groups/Index.cshtml diff --git a/Project-Unite/Controllers/GroupsController.cs b/Project-Unite/Controllers/GroupsController.cs new file mode 100644 index 0000000..96aa401 --- /dev/null +++ b/Project-Unite/Controllers/GroupsController.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/Project-Unite/Models/Group.cs b/Project-Unite/Models/Group.cs new file mode 100644 index 0000000..f59270b --- /dev/null +++ b/Project-Unite/Models/Group.cs @@ -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)); + } + } + + } +} \ No newline at end of file diff --git a/Project-Unite/Models/IdentityModels.cs b/Project-Unite/Models/IdentityModels.cs index 2e1bf31..46c8e56 100644 --- a/Project-Unite/Models/IdentityModels.cs +++ b/Project-Unite/Models/IdentityModels.cs @@ -30,6 +30,8 @@ namespace Project_Unite.Models // 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 GenerateUserIdentityAsync(UserManager manager) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType @@ -252,6 +254,7 @@ namespace Project_Unite.Models public DbSet Stories { get; set; } public DbSet Views { get; set; } public DbSet OAuthTokens { get; set; } + public DbSet Groups { get; set; } } public class OAuthToken diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj index 02325a5..e70f34c 100644 --- a/Project-Unite/Project-Unite.csproj +++ b/Project-Unite/Project-Unite.csproj @@ -256,6 +256,7 @@ + @@ -441,6 +442,7 @@ + @@ -587,6 +589,7 @@ + diff --git a/Project-Unite/Views/Groups/Index.cshtml b/Project-Unite/Views/Groups/Index.cshtml new file mode 100644 index 0000000..7364df0 --- /dev/null +++ b/Project-Unite/Views/Groups/Index.cshtml @@ -0,0 +1,50 @@ +@model IEnumerable + +@{ + ViewBag.Title = "Groups"; +} + +

Groups

+ +

Groups, formerly called Legions, are a way of grouping the community into different, well, groups, with their own tasks and goals.

+ +

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.

+ + + + + + + + + + @if(Model.Count() > 0) + { + foreach(var group in Model) + { + if (group.Publicity < 2) + { + + + + + + } + } + } + else + { + + + + + + } +
GroupUsersActions
+ @Html.ActionLink(group.Name, "ViewGroup", "Groups", new { id = group.Id }, null)
+

[@group.ShortName] • @group.Publicity.ToString()

+
+ @group.Users.Count() + + @Html.ActionLink("Join", "JoinGroup", "Groups", new { id=@group.Id}, new { @class="btn btn-default"}) +
No groups found! Be the first to create one!
\ No newline at end of file -- cgit v1.2.3