src/ZKEACMS.Product/Service/ProductService.cs

(开头部分) 8KB

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

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

using Easy.RepositoryPattern;
using System;
using System.Collections.Generic;
using ZKEACMS.Product.Models;
using Easy;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using Easy.Extend;
using Easy.Constant;
using System.Linq.Expressions;
using ZKEACMS.Event;

namespace ZKEACMS.Product.Service
{
    public class ProductService : ServiceBase<ProductEntity, CMSDbContext>, IProductService
    {
        private readonly IProductTagService _productTagService;
        private readonly IProductCategoryTagService _productCategoryTagService;
        private readonly IProductImageService _productImageService;
        private readonly ILocalize _localize;
        private readonly IEventManager _eventManager;
        public ProductService(IApplicationContext applicationContext,
            IProductTagService productTagService,
            IProductCategoryTagService productCategoryTagService,
            IProductImageService productImageService,
            ILocalize localize,
            IEventManager eventManager,
            CMSDbContext dbContext) : base(applicationContext, dbContext)
        {
            _productTagService = productTagService;
            _productCategoryTagService = productCategoryTagService;
            _productImageService = productImageService;
            _localize = localize;
            _eventManager = eventManager;
        }

        public void Publish(int ID)
        {
            Publish(Get(ID));
        }
        public override ServiceResult<ProductEntity> Add(ProductEntity item)
        {
            ServiceResult<ProductEntity> result = new ServiceResult<ProductEntity>();
            if (item.Url.IsNotNullAndWhiteSpace())
            {
                if (GetByUrl(item.Url) != null)
                {
                    result.RuleViolations.Add(new RuleViolation("Url", _localize.Get("URL already exists")));
                    return result;
                }
            }
            _eventManager.Trigger(Events.OnProductAdding, item);
            BeginTransaction(() =>
            {
                result = base.Add(item);
                if (!result.HasViolation)
后面还有 165 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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