src/ZKEACMS/Widget/WidgetService.cs

(开头部分) 8KB

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

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

using Easy;
using Easy.Extend;
using Easy.RepositoryPattern;
using Easy.Zip;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using ZKEACMS.Event;
using ZKEACMS.Page;

namespace ZKEACMS.Widget
{
    public abstract class WidgetService<T> : ServiceBase<T, CMSDbContext>, IWidgetPartDriver
        where T : WidgetBase
    {
        public WidgetService(IWidgetBasePartService widgetBasePartService, IApplicationContext applicationContext, CMSDbContext dbContext)
            : base(applicationContext, dbContext)
        {
            WidgetBasePartService = widgetBasePartService;
        }

        protected IWidgetBasePartService WidgetBasePartService { get; private set; }
        public override IQueryable<T> Get()
        {
            return CurrentDbSet.AsNoTracking();
        }
        public override ServiceResult<T> Add(T item)
        {
            return BeginTransaction(() =>
             {
                 var id = Guid.NewGuid().ToString("N");
                 var basePart = item.ToWidgetBasePart();
                 basePart.ID = id;
                 var baseResult = WidgetBasePartService.Add(basePart);
                 if (baseResult.HasViolation)
                 {
                     ServiceResult<T> result = new ServiceResult<T>();
                     foreach (var item in baseResult.RuleViolations)
                     {
                         result.AddRuleViolation(item.ParameterName, item.ErrorMessage);
                     }
                     return result;
                 }
                 item.ID = basePart.ID;
                 return base.Add(item);
             });
        }

后面还有 205 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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