Browse Source

Updated models to use virtual for all entity types. This allows Lazy Loading of all entities.

master
Teknikode 6 years ago
parent
commit
0bfe971504
  1. 2
      Teknik/Areas/API/Controllers/APIv1Controller.cs
  2. 28
      Teknik/Areas/Blog/Controllers/BlogController.cs
  3. 4
      Teknik/Areas/Blog/Models/Blog.cs
  4. 4
      Teknik/Areas/Blog/Models/BlogPost.cs
  5. 4
      Teknik/Areas/Blog/Models/BlogPostComment.cs
  6. 2
      Teknik/Areas/Blog/ViewModels/PostViewModel.cs
  7. 2
      Teknik/Areas/Paste/Models/Paste.cs
  8. 25
      Teknik/Areas/Podcast/Controllers/PodcastController.cs
  9. 4
      Teknik/Areas/Podcast/Models/Podcast.cs
  10. 4
      Teknik/Areas/Podcast/Models/PodcastComment.cs
  11. 2
      Teknik/Areas/Podcast/Models/PodcastFile.cs
  12. 2
      Teknik/Areas/Podcast/ViewModels/PodcastViewModel.cs
  13. 2
      Teknik/Areas/Shortener/Models/ShortenedUrl.cs
  14. 2
      Teknik/Areas/Transparency/Models/Takedown.cs
  15. 2
      Teknik/Areas/Upload/Controllers/UploadController.cs
  16. 2
      Teknik/Areas/Upload/Models/Upload.cs
  17. 21
      Teknik/Areas/Upload/Uploader.cs
  18. 4
      Teknik/Areas/User/Models/Group.cs
  19. 2
      Teknik/Areas/User/Models/RecoveryEmailVerification.cs
  20. 2
      Teknik/Areas/User/Models/ResetPasswordVerification.cs
  21. 2
      Teknik/Areas/User/Models/Role.cs
  22. 6
      Teknik/Areas/User/Models/User.cs
  23. 2
      Teknik/Areas/Vault/Models/PasteItem.cs
  24. 2
      Teknik/Areas/Vault/Models/UploadItem.cs
  25. 4
      Teknik/Areas/Vault/Models/Vault.cs
  26. 2
      Teknik/Areas/Vault/Models/VaultItem.cs

2
Teknik/Areas/API/Controllers/APIv1Controller.cs

@ -113,7 +113,7 @@ namespace Teknik.Areas.API.Controllers @@ -113,7 +113,7 @@ namespace Teknik.Areas.API.Controllers
}
// Save the file data
Upload.Models.Upload upload = Uploader.SaveFile((encrypt) ? data : fileData, contentType, contentLength, fileExt, iv, (saveKey) ? key : null, keySize, blockSize);
Upload.Models.Upload upload = Uploader.SaveFile(db, Config, (encrypt) ? data : fileData, contentType, contentLength, fileExt, iv, (saveKey) ? key : null, keySize, blockSize);
if (upload != null)
{

28
Teknik/Areas/Blog/Controllers/BlogController.cs

@ -32,7 +32,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -32,7 +32,7 @@ namespace Teknik.Areas.Blog.Controllers
ViewBag.Title = Config.BlogConfig.Title + " - " + Config.Title;
ViewBag.Description = Config.BlogConfig.Description;
bool isAuth = User.IsInRole("Admin");
var foundPosts = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => ((p.System || isAuth) && p.Published));
var foundPosts = db.BlogPosts.Where(p => ((p.System || isAuth) && p.Published));
model = new BlogViewModel();
model.BlogId = Config.BlogConfig.ServerBlogId;
@ -47,7 +47,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -47,7 +47,7 @@ namespace Teknik.Areas.Blog.Controllers
}
else // A user specific blog
{
Models.Blog blog = db.Blogs.Include("User").Where(p => p.User.Username == username && p.BlogId != Config.BlogConfig.ServerBlogId).FirstOrDefault();
Models.Blog blog = db.Blogs.Where(p => p.User.Username == username && p.BlogId != Config.BlogConfig.ServerBlogId).FirstOrDefault();
// find the blog specified
if (blog != null)
{
@ -58,7 +58,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -58,7 +58,7 @@ namespace Teknik.Areas.Blog.Controllers
}
ViewBag.Description = blog.User.BlogSettings.Description;
bool isAuth = User.IsInRole("Admin");
var foundPosts = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => (p.BlogId == blog.BlogId && !p.System) &&
var foundPosts = db.BlogPosts.Where(p => (p.BlogId == blog.BlogId && !p.System) &&
(p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
model = new BlogViewModel();
model.BlogId = blog.BlogId;
@ -87,7 +87,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -87,7 +87,7 @@ namespace Teknik.Areas.Blog.Controllers
PostViewModel model = new PostViewModel();
// find the post specified
bool isAuth = User.IsInRole("Admin");
var post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => (p.Blog.User.Username == username && p.BlogPostId == id) &&
var post = db.BlogPosts.Where(p => (p.Blog.User.Username == username && p.BlogPostId == id) &&
(p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (post != null)
{
@ -120,7 +120,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -120,7 +120,7 @@ namespace Teknik.Areas.Blog.Controllers
public ActionResult GetPosts(int blogID, int startPostID, int count)
{
bool isAuth = User.IsInRole("Admin");
var posts = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => ((p.BlogId == blogID && !p.System) || (p.System && blogID == Config.BlogConfig.ServerBlogId)) &&
var posts = db.BlogPosts.Where(p => ((p.BlogId == blogID && !p.System) || (p.System && blogID == Config.BlogConfig.ServerBlogId)) &&
(p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).OrderByDescending(p => p.DatePosted).Skip(startPostID).Take(count).ToList();
List<PostViewModel> postViews = new List<PostViewModel>();
if (posts != null)
@ -138,7 +138,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -138,7 +138,7 @@ namespace Teknik.Areas.Blog.Controllers
public ActionResult GetPostTitle(int postID)
{
bool isAuth = User.IsInRole("Admin");
BlogPost post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => (p.BlogPostId == postID) && (p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
BlogPost post = db.BlogPosts.Where(p => (p.BlogPostId == postID) && (p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (post != null)
{
return Json(new { result = post.Title });
@ -151,7 +151,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -151,7 +151,7 @@ namespace Teknik.Areas.Blog.Controllers
public ActionResult GetPostArticle(int postID)
{
bool isAuth = User.IsInRole("Admin");
BlogPost post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => (p.BlogPostId == postID) && (p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
BlogPost post = db.BlogPosts.Where(p => (p.BlogPostId == postID) && (p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (post != null)
{
return Json(new { result = post.Article });
@ -169,7 +169,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -169,7 +169,7 @@ namespace Teknik.Areas.Blog.Controllers
bool system = (blogID == Config.BlogConfig.ServerBlogId);
if (system)
{
var user = db.Blogs.Include("User").Where(b => b.User.Username == User.Identity.Name);
var user = db.Blogs.Where(b => b.User.Username == User.Identity.Name);
if (user != null)
{
blogID = user.First().BlogId;
@ -198,7 +198,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -198,7 +198,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPost post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => p.BlogPostId == postID).FirstOrDefault();
BlogPost post = db.BlogPosts.Where(p => p.BlogPostId == postID).FirstOrDefault();
if (post != null)
{
if (User.IsInRole("Admin") || post.Blog.User.Username == User.Identity.Name)
@ -222,7 +222,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -222,7 +222,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPost post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => p.BlogPostId == postID).FirstOrDefault();
BlogPost post = db.BlogPosts.Where(p => p.BlogPostId == postID).FirstOrDefault();
if (post != null)
{
if (User.IsInRole("Admin") || post.Blog.User.Username == User.Identity.Name)
@ -246,7 +246,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -246,7 +246,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPost post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => p.BlogPostId == postID).FirstOrDefault();
BlogPost post = db.BlogPosts.Where(p => p.BlogPostId == postID).FirstOrDefault();
if (post != null)
{
if (User.IsInRole("Admin") || post.Blog.User.Username == User.Identity.Name)
@ -268,7 +268,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -268,7 +268,7 @@ namespace Teknik.Areas.Blog.Controllers
[AllowAnonymous]
public ActionResult GetComments(int postID, int startCommentID, int count)
{
var comments = db.BlogComments.Include("BlogPost").Include("BlogPost.Blog").Include("BlogPost.Blog.User").Include("User").Where(p => (p.BlogPostId == postID)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
var comments = db.BlogComments.Where(p => (p.BlogPostId == postID)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
List<CommentViewModel> commentViews = new List<CommentViewModel>();
if (comments != null)
{
@ -320,7 +320,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -320,7 +320,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPostComment comment = db.BlogComments.Include("User").Where(c => c.BlogPostCommentId == commentID).FirstOrDefault();
BlogPostComment comment = db.BlogComments.Where(c => c.BlogPostCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))
@ -343,7 +343,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -343,7 +343,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPostComment comment = db.BlogComments.Include("User").Where(c => c.BlogPostCommentId == commentID).FirstOrDefault();
BlogPostComment comment = db.BlogComments.Where(c => c.BlogPostCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))

4
Teknik/Areas/Blog/Models/Blog.cs

@ -10,8 +10,8 @@ namespace Teknik.Areas.Blog.Models @@ -10,8 +10,8 @@ namespace Teknik.Areas.Blog.Models
public int UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public List<BlogPost> BlogPosts { get; set; }
public virtual ICollection<BlogPost> BlogPosts { get; set; }
}
}

4
Teknik/Areas/Blog/Models/BlogPost.cs

@ -10,7 +10,7 @@ namespace Teknik.Areas.Blog.Models @@ -10,7 +10,7 @@ namespace Teknik.Areas.Blog.Models
public int BlogId { get; set; }
public Blog Blog { get; set; }
public virtual Blog Blog { get; set; }
public bool System { get; set; }
@ -28,6 +28,6 @@ namespace Teknik.Areas.Blog.Models @@ -28,6 +28,6 @@ namespace Teknik.Areas.Blog.Models
public List<string> Tags { get; set; }
public List<BlogPostComment> Comments { get; set; }
public virtual ICollection<BlogPostComment> Comments { get; set; }
}
}

4
Teknik/Areas/Blog/Models/BlogPostComment.cs

@ -12,11 +12,11 @@ namespace Teknik.Areas.Blog.Models @@ -12,11 +12,11 @@ namespace Teknik.Areas.Blog.Models
public int BlogPostId { get; set; }
public BlogPost BlogPost { get; set; }
public virtual BlogPost BlogPost { get; set; }
public int? UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public DateTime DatePosted { get; set; }
public DateTime DateEdited { get; set; }

2
Teknik/Areas/Blog/ViewModels/PostViewModel.cs

@ -52,7 +52,7 @@ namespace Teknik.Areas.Blog.ViewModels @@ -52,7 +52,7 @@ namespace Teknik.Areas.Blog.ViewModels
Title = post.Title;
Tags = post.Tags;
Article = post.Article;
Comments = post.Comments;
Comments = post.Comments.ToList();
}
}
}

2
Teknik/Areas/Paste/Models/Paste.cs

@ -13,7 +13,7 @@ namespace Teknik.Areas.Paste.Models @@ -13,7 +13,7 @@ namespace Teknik.Areas.Paste.Models
public int? UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public DateTime DatePosted { get; set; }

25
Teknik/Areas/Podcast/Controllers/PodcastController.cs

@ -59,7 +59,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -59,7 +59,7 @@ namespace Teknik.Areas.Podcast.Controllers
PodcastViewModel model = new PodcastViewModel();
// find the podcast specified
bool editor = User.IsInRole("Podcast");
var foundPodcast = db.Podcasts.Include("Files").Where(p => ((p.Published || editor) && p.Episode == episode)).FirstOrDefault();
var foundPodcast = db.Podcasts.Where(p => ((p.Published || editor) && p.Episode == episode)).FirstOrDefault();
if (foundPodcast != null)
{
model = new PodcastViewModel(foundPodcast);
@ -76,7 +76,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -76,7 +76,7 @@ namespace Teknik.Areas.Podcast.Controllers
public ActionResult Download(int episode, string fileName)
{
// find the podcast specified
var foundPodcast = db.Podcasts.Include("Files").Where(p => (p.Published && p.Episode == episode)).FirstOrDefault();
var foundPodcast = db.Podcasts.Where(p => (p.Published && p.Episode == episode)).FirstOrDefault();
if (foundPodcast != null)
{
PodcastFile file = foundPodcast.Files.Where(f => f.FileName == fileName).FirstOrDefault();
@ -108,7 +108,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -108,7 +108,7 @@ namespace Teknik.Areas.Podcast.Controllers
public ActionResult GetPodcasts(int startPodcastID, int count)
{
bool editor = User.IsInRole("Podcast");
var podcasts = db.Podcasts.Include("Files").Where(p => p.Published || editor).OrderByDescending(p => p.DatePosted).Skip(startPodcastID).Take(count).ToList();
var podcasts = db.Podcasts.Where(p => p.Published || editor).OrderByDescending(p => p.DatePosted).Skip(startPodcastID).Take(count).ToList();
List<PodcastViewModel> podcastViews = new List<PodcastViewModel>();
if (podcasts != null)
{
@ -164,7 +164,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -164,7 +164,7 @@ namespace Teknik.Areas.Podcast.Controllers
public ActionResult GetPodcastFiles(int podcastId)
{
bool editor = User.IsInRole("Podcast");
var foundPodcast = db.Podcasts.Include("Files").Where(p => ((p.Published || editor) && p.PodcastId == podcastId)).FirstOrDefault();
var foundPodcast = db.Podcasts.Where(p => ((p.Published || editor) && p.PodcastId == podcastId)).FirstOrDefault();
if (foundPodcast != null)
{
List<object> files = new List<object>();
@ -221,7 +221,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -221,7 +221,7 @@ namespace Teknik.Areas.Podcast.Controllers
{
if (User.IsInRole("Podcast"))
{
Models.Podcast podcast = db.Podcasts.Include("Files").Where(p => p.PodcastId == podcastId).FirstOrDefault();
Models.Podcast podcast = db.Podcasts.Where(p => p.PodcastId == podcastId).FirstOrDefault();
if (podcast != null)
{
if (db.Podcasts.Where(p => p.Episode != episode).FirstOrDefault() == null || podcast.Episode == episode)
@ -238,7 +238,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -238,7 +238,7 @@ namespace Teknik.Areas.Podcast.Controllers
}
for (int i = 0; i < podcast.Files.Count; i++)
{
PodcastFile curFile = podcast.Files[i];
PodcastFile curFile = podcast.Files.ElementAt(i);
if (!fileIdList.Exists(id => id == curFile.PodcastFileId.ToString()))
{
if (System.IO.File.Exists(curFile.Path))
@ -251,7 +251,10 @@ namespace Teknik.Areas.Podcast.Controllers @@ -251,7 +251,10 @@ namespace Teknik.Areas.Podcast.Controllers
}
// Add any new files
List<PodcastFile> newFiles = SaveFiles(Request.Files, episode);
podcast.Files.AddRange(newFiles);
foreach (PodcastFile file in newFiles)
{
podcast.Files.Add(file);
}
// Save podcast
db.Entry(podcast).State = EntityState.Modified;
@ -298,7 +301,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -298,7 +301,7 @@ namespace Teknik.Areas.Podcast.Controllers
{
if (User.IsInRole("Podcast"))
{
Models.Podcast podcast = db.Podcasts.Include("Files").Where(p => p.PodcastId == podcastId).FirstOrDefault();
Models.Podcast podcast = db.Podcasts.Where(p => p.PodcastId == podcastId).FirstOrDefault();
if (podcast != null)
{
foreach (PodcastFile file in podcast.Files)
@ -322,7 +325,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -322,7 +325,7 @@ namespace Teknik.Areas.Podcast.Controllers
[AllowAnonymous]
public ActionResult GetComments(int podcastId, int startCommentID, int count)
{
var comments = db.PodcastComments.Include("BlogPost").Include("BlogPost.Blog").Include("BlogPost.Blog.User").Include("User").Where(p => (p.PodcastId == podcastId)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
var comments = db.PodcastComments.Where(p => (p.PodcastId == podcastId)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
List<CommentViewModel> commentViews = new List<CommentViewModel>();
if (comments != null)
{
@ -374,7 +377,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -374,7 +377,7 @@ namespace Teknik.Areas.Podcast.Controllers
{
if (ModelState.IsValid)
{
PodcastComment comment = db.PodcastComments.Include("User").Where(c => c.PodcastCommentId == commentID).FirstOrDefault();
PodcastComment comment = db.PodcastComments.Where(c => c.PodcastCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))
@ -397,7 +400,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -397,7 +400,7 @@ namespace Teknik.Areas.Podcast.Controllers
{
if (ModelState.IsValid)
{
PodcastComment comment = db.PodcastComments.Include("User").Where(c => c.PodcastCommentId == commentID).FirstOrDefault();
PodcastComment comment = db.PodcastComments.Where(c => c.PodcastCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))

4
Teknik/Areas/Podcast/Models/Podcast.cs

@ -15,7 +15,7 @@ namespace Teknik.Areas.Podcast.Models @@ -15,7 +15,7 @@ namespace Teknik.Areas.Podcast.Models
public string Description { get; set; }
public List<PodcastFile> Files { get; set; }
public virtual ICollection<PodcastFile> Files { get; set; }
public List<string> Tags { get; set; }
@ -27,6 +27,6 @@ namespace Teknik.Areas.Podcast.Models @@ -27,6 +27,6 @@ namespace Teknik.Areas.Podcast.Models
public DateTime DateEdited { get; set; }
public List<PodcastComment> Comments { get; set; }
public virtual ICollection<PodcastComment> Comments { get; set; }
}
}

4
Teknik/Areas/Podcast/Models/PodcastComment.cs

@ -12,11 +12,11 @@ namespace Teknik.Areas.Podcast.Models @@ -12,11 +12,11 @@ namespace Teknik.Areas.Podcast.Models
public int PodcastId { get; set; }
public Podcast Podcast { get; set; }
public virtual Podcast Podcast { get; set; }
public int UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public DateTime DatePosted { get; set; }

2
Teknik/Areas/Podcast/Models/PodcastFile.cs

@ -11,7 +11,7 @@ namespace Teknik.Areas.Podcast.Models @@ -11,7 +11,7 @@ namespace Teknik.Areas.Podcast.Models
public int PodcastId { get; set; }
public Podcast Podcast { get; set; }
public virtual Podcast Podcast { get; set; }
public string FileName { get; set; }

2
Teknik/Areas/Podcast/ViewModels/PodcastViewModel.cs

@ -37,7 +37,7 @@ namespace Teknik.Areas.Podcast.ViewModels @@ -37,7 +37,7 @@ namespace Teknik.Areas.Podcast.ViewModels
Episode = podcast.Episode;
Title = podcast.Title;
Description = podcast.Description;
Files = podcast.Files;
Files = podcast.Files.ToList();
Tags = podcast.Tags;
DatePosted = podcast.DatePosted;
Published = podcast.Published;

2
Teknik/Areas/Shortener/Models/ShortenedUrl.cs

@ -12,7 +12,7 @@ namespace Teknik.Areas.Shortener.Models @@ -12,7 +12,7 @@ namespace Teknik.Areas.Shortener.Models
public int? UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public string ShortUrl { get; set; }

2
Teknik/Areas/Transparency/Models/Takedown.cs

@ -22,6 +22,6 @@ namespace Teknik.Areas.Transparency.Models @@ -22,6 +22,6 @@ namespace Teknik.Areas.Transparency.Models
public DateTime DateActionTaken { get; set; }
public List<Upload.Models.Upload> Attachments { get; set; }
public virtual ICollection<Upload.Models.Upload> Attachments { get; set; }
}
}

2
Teknik/Areas/Upload/Controllers/UploadController.cs

@ -110,7 +110,7 @@ namespace Teknik.Areas.Upload.Controllers @@ -110,7 +110,7 @@ namespace Teknik.Areas.Upload.Controllers
return Json(new { error = new { message = "Unable to encrypt file" } });
}
}
Models.Upload upload = Uploader.SaveFile(fileData, fileType, contentLength, fileExt, iv, (saveKey) ? key : null, keySize, blockSize);
Models.Upload upload = Uploader.SaveFile(db, Config, fileData, fileType, contentLength, fileExt, iv, (saveKey) ? key : null, keySize, blockSize);
if (upload != null)
{
if (User.Identity.IsAuthenticated)

2
Teknik/Areas/Upload/Models/Upload.cs

@ -12,7 +12,7 @@ namespace Teknik.Areas.Upload.Models @@ -12,7 +12,7 @@ namespace Teknik.Areas.Upload.Models
public int? UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public DateTime DateUploaded { get; set; }

21
Teknik/Areas/Upload/Uploader.cs

@ -10,30 +10,27 @@ namespace Teknik.Areas.Upload @@ -10,30 +10,27 @@ namespace Teknik.Areas.Upload
{
public static class Uploader
{
public static Models.Upload SaveFile(byte[] file, string contentType, int contentLength)
public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength)
{
return SaveFile(file, contentType, contentLength, string.Empty, null, null, 256, 128);
return SaveFile(db, config, file, contentType, contentLength, string.Empty, null, null, 256, 128);
}
public static Models.Upload SaveFile(byte[] file, string contentType, int contentLength, string defaultExtension)
public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension)
{
return SaveFile(file, contentType, contentLength, defaultExtension, null, null, 256, 128);
return SaveFile(db, config, file, contentType, contentLength, defaultExtension, null, null, 256, 128);
}
public static Models.Upload SaveFile(byte[] file, string contentType, int contentLength, string defaultExtension, string iv)
public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension, string iv)
{
return SaveFile(file, contentType, contentLength, defaultExtension, iv, null, 256, 128);
return SaveFile(db, config, file, contentType, contentLength, defaultExtension, iv, null, 256, 128);
}
public static Models.Upload SaveFile(byte[] file, string contentType, int contentLength, string defaultExtension, string iv, string key)
public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension, string iv, string key)
{
return SaveFile(file, contentType, contentLength, defaultExtension, iv, key, 256, 128);
return SaveFile(db, config, file, contentType, contentLength, defaultExtension, iv, key, 256, 128);
}
public static Models.Upload SaveFile(byte[] file, string contentType, int contentLength, string defaultExtension, string iv, string key, int keySize, int blockSize)
public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension, string iv, string key, int keySize, int blockSize)
{
Config config = Config.Load();
TeknikEntities db = new TeknikEntities();
if (!Directory.Exists(config.UploadConfig.UploadDirectory))
{
Directory.CreateDirectory(config.UploadConfig.UploadDirectory);

4
Teknik/Areas/User/Models/Group.cs

@ -14,8 +14,8 @@ namespace Teknik.Areas.Users.Models @@ -14,8 +14,8 @@ namespace Teknik.Areas.Users.Models
public string Description { get; set; }
public List<User> Users { get; set; }
public virtual ICollection<User> Users { get; set; }
public List<Role> Roles { get; set; }
public virtual ICollection<Role> Roles { get; set; }
}
}

2
Teknik/Areas/User/Models/RecoveryEmailVerification.cs

@ -11,7 +11,7 @@ namespace Teknik.Areas.Users.Models @@ -11,7 +11,7 @@ namespace Teknik.Areas.Users.Models
public int UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public string Code { get; set; }

2
Teknik/Areas/User/Models/ResetPasswordVerification.cs

@ -11,7 +11,7 @@ namespace Teknik.Areas.Users.Models @@ -11,7 +11,7 @@ namespace Teknik.Areas.Users.Models
public int UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public string Code { get; set; }

2
Teknik/Areas/User/Models/Role.cs

@ -14,6 +14,6 @@ namespace Teknik.Areas.Users.Models @@ -14,6 +14,6 @@ namespace Teknik.Areas.Users.Models
public string Description { get; set; }
public List<Group> Groups { get; set; }
public virtual ICollection<Group> Groups { get; set; }
}
}

6
Teknik/Areas/User/Models/User.cs

@ -24,7 +24,7 @@ namespace Teknik.Areas.Users.Models @@ -24,7 +24,7 @@ namespace Teknik.Areas.Users.Models
public DateTime LastSeen { get; set; }
public List<Group> Groups { get; set; }
public virtual ICollection<Group> Groups { get; set; }
public virtual UserSettings UserSettings { get; set; }
@ -32,9 +32,9 @@ namespace Teknik.Areas.Users.Models @@ -32,9 +32,9 @@ namespace Teknik.Areas.Users.Models
public virtual UploadSettings UploadSettings { get; set; }
public List<Upload.Models.Upload> Uploads { get; set; }
public virtual ICollection<Upload.Models.Upload> Uploads { get; set; }
public List<Paste.Models.Paste> Pastes { get; set; }
public virtual ICollection<Paste.Models.Paste> Pastes { get; set; }
public User()
{

2
Teknik/Areas/Vault/Models/PasteItem.cs

@ -8,6 +8,6 @@ namespace Teknik.Areas.Vault.Models @@ -8,6 +8,6 @@ namespace Teknik.Areas.Vault.Models
public class PasteItem : VaultItem
{
public int PasteId { get; set; }
public Paste.Models.Paste Paste { get; set; }
public virtual Paste.Models.Paste Paste { get; set; }
}
}

2
Teknik/Areas/Vault/Models/UploadItem.cs

@ -8,6 +8,6 @@ namespace Teknik.Areas.Vault.Models @@ -8,6 +8,6 @@ namespace Teknik.Areas.Vault.Models
public class UploadItem : VaultItem
{
public int UploadId { get; set; }
public Upload.Models.Upload Upload { get; set; }
public virtual Upload.Models.Upload Upload { get; set; }
}
}

4
Teknik/Areas/Vault/Models/Vault.cs

@ -9,12 +9,12 @@ namespace Teknik.Areas.Vault.Models @@ -9,12 +9,12 @@ namespace Teknik.Areas.Vault.Models
{
public int VaultId { get; set; }
public int? UserId { get; set; }
public Users.Models.User User { get; set; }
public virtual Users.Models.User User { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateEdited { get; set; }
public List<VaultItem> Items { get; set; }
public virtual ICollection<VaultItem> Items { get; set; }
public Vault()
{

2
Teknik/Areas/Vault/Models/VaultItem.cs

@ -8,6 +8,8 @@ namespace Teknik.Areas.Vault.Models @@ -8,6 +8,8 @@ namespace Teknik.Areas.Vault.Models
public class VaultItem
{
public int VaultItemId { get; set; }
public int VaultId { get; set; }
public virtual Vault Vault { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public DateTime DateAdded { get; set; }

Loading…
Cancel
Save