summaryrefslogtreecommitdiff
path: root/Project-Unite/Models
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-04-07 21:13:44 -0400
committerMichael <[email protected]>2017-04-07 21:13:44 -0400
commitb1e6d3dee9fa6519c65dd7564eac02b9e68bc3ce (patch)
treedbff9719e4e9985951127c65db2be28fc6a46605 /Project-Unite/Models
parent1de8bc4bd0af72646ed58ecd7619a8731c48b09d (diff)
downloadproject-unite-b1e6d3dee9fa6519c65dd7564eac02b9e68bc3ce.tar.gz
project-unite-b1e6d3dee9fa6519c65dd7564eac02b9e68bc3ce.tar.bz2
project-unite-b1e6d3dee9fa6519c65dd7564eac02b9e68bc3ce.zip
Developer blog
Diffstat (limited to 'Project-Unite/Models')
-rw-r--r--Project-Unite/Models/BlogModels.cs65
-rw-r--r--Project-Unite/Models/IdentityModels.cs1
2 files changed, 66 insertions, 0 deletions
diff --git a/Project-Unite/Models/BlogModels.cs b/Project-Unite/Models/BlogModels.cs
new file mode 100644
index 0000000..00ffbea
--- /dev/null
+++ b/Project-Unite/Models/BlogModels.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+
+namespace Project_Unite.Models
+{
+ public class PostBlogViewModel
+ {
+ [Required(ErrorMessage="Please enter a name for your post!")]
+ [MinLength(5, ErrorMessage ="Your post's name must have at least 5 characters.")]
+ [MaxLength(50, ErrorMessage = "Your post's name must have at least 50 characters.")]
+ public string Name { get; set; }
+
+ [AllowHtml]
+ [Required(ErrorMessage ="You can't post an empty blog post!")]
+ [MinLength(20, ErrorMessage = "Your post must have at least 20 characters.")]
+ public string Contents { get; set; }
+ }
+
+ public class BlogPost
+ {
+ public string Id { get; set; }
+ public string AuthorId { get; set; }
+ public ForumPost[] Comments
+ {
+ get
+ {
+ return new ApplicationDbContext().ForumPosts.Where(x => x.Parent == this.Id).ToArray();
+ }
+ }
+ public Like[] Likes
+ {
+ get
+ {
+ return new ApplicationDbContext().Likes.Where(x => x.Topic == this.Id&&x.IsDislike == false).ToArray();
+ }
+ }
+
+ public string Name { get; set; }
+
+ public string Summary
+ {
+ get
+ {
+ return Contents.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)[0];
+ }
+ }
+
+ public Like[] Dislikes
+ {
+ get
+ {
+ return new ApplicationDbContext().Likes.Where(x => x.Topic == this.Id && x.IsDislike == true).ToArray();
+
+ }
+ }
+
+ public DateTime PostedAt { get; set; }
+
+ public string Contents { get; set; }
+ }
+} \ No newline at end of file
diff --git a/Project-Unite/Models/IdentityModels.cs b/Project-Unite/Models/IdentityModels.cs
index cf04def..42f9e30 100644
--- a/Project-Unite/Models/IdentityModels.cs
+++ b/Project-Unite/Models/IdentityModels.cs
@@ -219,6 +219,7 @@ namespace Project_Unite.Models
return new ApplicationDbContext();
}
+ public DbSet<BlogPost> BlogPosts { get; set; }
public DbSet<ReadPost> ReadPosts { get; set; }
public DbSet<Download> Downloads { get; set; }
public DbSet<DatabaseBackup> Backups { get; set; }