示例#1
0
        /// <summary>
        /// Gets the specified author.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>
        ///   <c>GetAuthorRequest</c> with an author.
        /// </returns>
        public GetAuthorResponse Get(GetAuthorRequest request)
        {
            var query = repository.AsQueryable <Module.Blog.Models.Author>();

            query = query.Where(author => author.Id == request.AuthorId);

            var model = query
                        .Select(author => new AuthorModel
            {
                Id             = author.Id,
                Version        = author.Version,
                CreatedBy      = author.CreatedByUser,
                CreatedOn      = author.CreatedOn,
                LastModifiedBy = author.ModifiedByUser,
                LastModifiedOn = author.ModifiedOn,

                Name        = author.Name,
                Description = author.Description,

                ImageId           = author.Image != null && !author.Image.IsDeleted ? author.Image.Id : (Guid?)null,
                ImageUrl          = author.Image != null && !author.Image.IsDeleted ? author.Image.PublicUrl : (string)null,
                ImageThumbnailUrl = author.Image != null && !author.Image.IsDeleted ? author.Image.PublicThumbnailUrl : (string)null,
                ImageCaption      = author.Image != null && !author.Image.IsDeleted ? author.Image.Caption : (string)null
            })
                        .FirstOne();

            model.ImageUrl          = fileUrlResolver.EnsureFullPathUrl(model.ImageUrl);
            model.ImageThumbnailUrl = fileUrlResolver.EnsureFullPathUrl(model.ImageThumbnailUrl);

            return(new GetAuthorResponse
            {
                Data = model
            });
        }
示例#2
0
        public GetAuthorResponse Get(GetAuthorRequest request)
        {
            var query = repository.AsQueryable <Module.Blog.Models.Author>();

            query = query.Where(author => author.Id == request.AuthorId);

            var model = query
                        .Select(author => new AuthorModel
            {
                Id             = author.Id,
                Version        = author.Version,
                CreatedBy      = author.CreatedByUser,
                CreatedOn      = author.CreatedOn,
                LastModifiedBy = author.ModifiedByUser,
                LastModifiedOn = author.ModifiedOn,

                Name              = author.Name,
                ImageId           = author.Image.Id,
                ImageUrl          = author.Image.PublicUrl,
                ImageThumbnailUrl = author.Image.PublicThumbnailUrl,
                ImageCaption      = author.Image.Caption
            })
                        .FirstOne();

            return(new GetAuthorResponse
            {
                Data = model
            });
        }