示例#1
0
        public static PricingModel ToViewModel(this Pricing entity, IPricingService pricingService, IMDocumentService documentService)
        {
            var img = new MDocument();

            if (!string.IsNullOrWhiteSpace(entity.ImageId))
            {
                img = documentService.GetById(entity.ImageId);
            }

            var modelVm = new PricingModel()
            {
                Id               = entity.Id,
                CreatedBy        = entity.CreatedBy,
                CreatedDate      = entity.CreatedDate,
                Description      = entity.Description,
                ViewCount        = entity.ViewCount,
                ImageId          = entity.ImageId,
                Name             = entity.Name,
                Published        = entity.Published,
                ShortDescription = entity.ShortDescription,
                ImageUrl         = img?.FileUrl
            };

            return(modelVm);
        }
示例#2
0
        public static SettingModel ToModel(this Setting entity, IMDocumentService documentService)
        {
            var img = new MDocument();

            if (!string.IsNullOrWhiteSpace(entity.FileId))
            {
                img = documentService.GetById(entity.FileId);
            }

            var modelVm = new SettingModel()
            {
                Id          = entity.Id,
                CODE        = entity.CODE,
                CreatedBy   = entity.CreatedBy,
                CreatedDate = entity.CreatedDate,
                FileId      = entity.FileId,
                HTMLContent = entity.HTMLContent,
                Published   = entity.Published,
                FileUrl     = img?.FileUrl,
                Show        = entity.Show,
                Type        = entity.Type
            };

            return(modelVm);
        }
示例#3
0
        public static BlogModel ToViewModel(this Blog entity, IBlogService blogService, ICategoryService categoryService, IMDocumentService documentService)
        {
            var img = new MDocument();

            if (!string.IsNullOrWhiteSpace(entity.ImageId))
            {
                img = documentService.GetById(entity.ImageId);
            }

            var categoryId = blogService.GetCategoryId(entity.Id);
            var category   = categoryService.GetById(categoryId);

            var modelVm = new BlogModel()
            {
                Id               = entity.Id,
                CategoryId       = categoryId,
                CategoryName     = category?.Name,
                CreatedBy        = entity.CreatedBy,
                CreatedDate      = entity.CreatedDate,
                Description      = entity.Description,
                ViewCount        = entity.ViewCount,
                ImageId          = entity.ImageId,
                Name             = entity.Name,
                Published        = entity.Published,
                ShortDescription = entity.ShortDescription,
                ImageUrl         = img?.FileUrl,
                Categories       = categoryService.GetAll().Select(x => new SelectListItem()
                {
                    Selected = categoryId == x.Id, Text = x.Name, Value = x.Id
                }).ToList(),
                Alias        = entity.Alias,
                DisplayOrder = entity.DisplayOrder,
                ShowAtHome   = entity.ShowAtHome
            };

            return(modelVm);
        }