diff options
| author | Michael <[email protected]> | 2017-04-07 21:13:44 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-04-07 21:13:44 -0400 |
| commit | b1e6d3dee9fa6519c65dd7564eac02b9e68bc3ce (patch) | |
| tree | dbff9719e4e9985951127c65db2be28fc6a46605 /Project-Unite/Models/BlogModels.cs | |
| parent | 1de8bc4bd0af72646ed58ecd7619a8731c48b09d (diff) | |
| download | project-unite-b1e6d3dee9fa6519c65dd7564eac02b9e68bc3ce.tar.gz project-unite-b1e6d3dee9fa6519c65dd7564eac02b9e68bc3ce.tar.bz2 project-unite-b1e6d3dee9fa6519c65dd7564eac02b9e68bc3ce.zip | |
Developer blog
Diffstat (limited to 'Project-Unite/Models/BlogModels.cs')
| -rw-r--r-- | Project-Unite/Models/BlogModels.cs | 65 |
1 files changed, 65 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 |
