Browse Source

- Added Vault list to user profile.

- Added view count for vaults.
pull/50/head
Teknikode 6 years ago
parent
commit
20404c829a
  1. 2
      Teknik/Areas/User/Controllers/UserController.cs
  2. 2
      Teknik/Areas/User/ViewModels/ProfileViewModel.cs
  3. 27
      Teknik/Areas/User/Views/User/ViewProfile.cshtml
  4. 5
      Teknik/Areas/Vault/Controllers/VaultController.cs
  5. 11
      Teknik/Areas/Vault/Models/Vault.cs

2
Teknik/Areas/User/Controllers/UserController.cs

@ -68,6 +68,8 @@ namespace Teknik.Areas.Users.Controllers @@ -68,6 +68,8 @@ namespace Teknik.Areas.Users.Controllers
model.ShortenedUrls = db.ShortenedUrls.Where(s => s.UserId == user.UserId).OrderByDescending(s => s.DateAdded).ToList();
model.Vaults = db.Vaults.Where(v => v.UserId == user.UserId).OrderByDescending(v => v.DateCreated).ToList();
return View(model);
}
model.Error = true;

2
Teknik/Areas/User/ViewModels/ProfileViewModel.cs

@ -25,6 +25,8 @@ namespace Teknik.Areas.Users.ViewModels @@ -25,6 +25,8 @@ namespace Teknik.Areas.Users.ViewModels
public List<Shortener.Models.ShortenedUrl> ShortenedUrls { get; set; }
public List<Vault.Models.Vault> Vaults { get; set; }
public UserSettings UserSettings { get; set; }
public SecuritySettings SecuritySettings { get; set; }

27
Teknik/Areas/User/Views/User/ViewProfile.cshtml

@ -120,6 +120,7 @@ @@ -120,6 +120,7 @@
<li><a href="#uploads" data-toggle="tab"> Uploads </a></li>
<li><a href="#pastes" data-toggle="tab"> Pastes </a></li>
<li><a href="#shortenedUrls" data-toggle="tab"> Shortened Urls </a></li>
<li><a href="#vaults" data-toggle="tab"> Vaults </a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="about">
@ -229,7 +230,31 @@ @@ -229,7 +230,31 @@
</div>
}
</div>
}
<div class="tab-pane" id="vaults" style="overflow-y: auto; max-height: 500px;">
@foreach (Teknik.Areas.Vault.Models.Vault vault in Model.Vaults)
{
<div class="panel panel-default">
<div class="panel-heading text-center">
<a href="@Url.SubRouteUrl("v", "Vault.ViewVault", new { id = vault.Url })">@(string.IsNullOrEmpty(vault.Title) ? "Vault" : vault.Title)</a>
</div>
<div class="panel-body">
<div class="col-sm-5 text-center">
<label for="dateAdded">Date Created</label>
<p id="dateAdded"><time datetime="@vault.DateCreated.ToString("s")">@vault.DateCreated.ToString("MMMM dd, yyyy")</time></p>
</div>
<div class="col-sm-5 text-center">
<label for="dateAdded">Date Edited</label>
<p id="dateAdded"><time datetime="@vault.DateEdited.ToString("s")">@vault.DateEdited.ToString("MMMM dd, yyyy")</time></p>
</div>
<div class="col-sm-2 text-center">
<label for="views">Views</label>
<p id="views">@vault.Views</p>
</div>
</div>
</div>
}
</div>
}
</div><!--/tab-content-->
}
else

5
Teknik/Areas/Vault/Controllers/VaultController.cs

@ -28,6 +28,11 @@ namespace Teknik.Areas.Vault.Controllers @@ -28,6 +28,11 @@ namespace Teknik.Areas.Vault.Controllers
Models.Vault foundVault = db.Vaults.Where(v => v.Url == id).FirstOrDefault();
if (foundVault != null)
{
// Update view count
foundVault.Views += 1;
db.Entry(foundVault).State = EntityState.Modified;
db.SaveChanges();
ViewBag.Title = foundVault.Title + " - Vault";
VaultViewModel model = new VaultViewModel();

11
Teknik/Areas/Vault/Models/Vault.cs

@ -8,13 +8,23 @@ namespace Teknik.Areas.Vault.Models @@ -8,13 +8,23 @@ namespace Teknik.Areas.Vault.Models
public class Vault
{
public int VaultId { get; set; }
public int? UserId { get; set; }
public virtual Users.Models.User User { get; set; }
public string Url { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateEdited { get; set; }
public int Views { get; set; }
public virtual ICollection<VaultItem> Items { get; set; }
public Vault()
@ -23,6 +33,7 @@ namespace Teknik.Areas.Vault.Models @@ -23,6 +33,7 @@ namespace Teknik.Areas.Vault.Models
Description = string.Empty;
DateCreated = DateTime.Now;
DateEdited = DateTime.Now;
Views = 0;
Items = new List<VaultItem>();
}
}

Loading…
Cancel
Save