src/ZKEACMS.SectionWidget/Service/SectionContentProviderService.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using System.Collections.Generic;
using System.Linq;
using ZKEACMS.SectionWidget.Models;
using Easy.RepositoryPattern;
using Easy;
using Microsoft.EntityFrameworkCore;
using System;
using Easy.Extend;

namespace ZKEACMS.SectionWidget.Service
{
    public class SectionContentProviderService : ServiceBase<SectionContentBasePart, CMSDbContext>, ISectionContentProviderService
    {
        private readonly IEnumerable<ISectionContentService> _sectionContentServices;

        public SectionContentProviderService(IEnumerable<ISectionContentService> sectionContentServices, IApplicationContext applicationContext, CMSDbContext dbContext)
            : base(applicationContext, dbContext)
        {
            _sectionContentServices = sectionContentServices;
        }
        public override IQueryable<SectionContentBasePart> Get()
        {
            return CurrentDbSet.AsNoTracking();
        }
        public void Add(SectionContent item)
        {
            if (!item.Order.HasValue || item.Order.Value == 0)
            {
                item.Order = Count(m => m.SectionWidgetId == item.SectionWidgetId && m.SectionGroupId == item.SectionGroupId) + 1;
            }
            var contentBase = item.ToContent();
            contentBase.ID = Guid.NewGuid().ToString("N");
            base.Add(contentBase);
            item.ID = contentBase.ID;
            _sectionContentServices.First(m => (int)m.ContentType == item.SectionContentType).AddContent(item);
        }
        public void Update(SectionContent item)
        {
            var content = Get(item.ID);
            item.CopyTo(content);
            base.Update(content);
            _sectionContentServices.First(m => (int)m.ContentType == item.SectionContentType).UpdateContent(item);
        }


        public SectionContent GetContent(string contentId)
        {
            var item = base.Get(contentId);
            if (item != null)
            {
                var result = _sectionContentServices.First(m => (int)m.ContentType == item.SectionContentType).GetContent(item.ID);
                result.Order = item.Order;
                result.SectionGroupId = item.SectionGroupId;
                result.SectionWidgetId = item.SectionWidgetId;
                return result;
            }
后面还有 27 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。