Beispiel #1
0
		/// <summary>
		/// Gets the view model for the comment list view.
		/// </summary>
		/// <returns>The model</returns>
		public static CommentListModel Get() {
			var m = new CommentListModel() ;

			using (var db = new DataContext()) {
				m.Comments = db.Comments.Select(c => new CommentModel() {
					Id = c.Id,
					Title = !String.IsNullOrEmpty(c.Title) ? c.Title : c.Body.Substring(0, 32) + "...",
					Created = c.Created,
					AuthorName = c.AuthorName,
					AuthorEmail = c.AuthorEmail,
					Status = (Comment.CommentStatus)c.InternalStatus,
				}).OrderByDescending(c => c.Created).ToList() ;
			}
			return m ;
		}
        /// <summary>
        /// Gets the view model for the comment list view.
        /// </summary>
        /// <returns>The model</returns>
        public static CommentListModel Get()
        {
            var m = new CommentListModel();

            using (var db = new DataContext()) {
                m.Comments = db.Comments.Include("CreatedBy").Select(c => new CommentModel()
                {
                    Id          = c.Id,
                    Title       = !String.IsNullOrEmpty(c.Title) ? c.Title : c.Body.Substring(0, 32) + "...",
                    Created     = c.Created,
                    AuthorName  = c.CreatedBy != null ? c.CreatedBy.Firstname + " " + c.CreatedBy.Surname : c.AuthorName,
                    AuthorEmail = c.CreatedBy != null ? c.CreatedBy.Email : c.AuthorEmail,
                    Status      = (Comment.CommentStatus)c.InternalStatus,
                }).OrderByDescending(c => c.Created).ToList();
            }
            return(m);
        }