src/ZKEACMS.Article/Service/ArticleTypeApiService.cs
(开头部分) 1KB这里只显示每个文件的开头 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 System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZKEACMS.Article.Models;
namespace ZKEACMS.Article.Service
{
public class ArticleTypeApiService : IArticleTypeApiService
{
private readonly IArticleTypeService _articleTypeService;
public ArticleTypeApiService(IArticleTypeService articleTypeService)
{
_articleTypeService = articleTypeService;
}
public ServiceResult<ArticleType> Create(ArticleType articleType)
{
var validResult= ValidParentId(articleType);
if (validResult.HasViolation) return validResult;
return _articleTypeService.Add(articleType);
}
private ServiceResult<ArticleType> ValidParentId(ArticleType articleType)
{
ServiceResult<ArticleType> result = new ServiceResult<ArticleType>();
if (articleType.ParentID.HasValue)
{
var parentArticleType = _articleTypeService.Get(articleType.ParentID.Value);
if (parentArticleType == null)
{
result.AddRuleViolation("ParentID", "Parent is not exist");
}
}
return result;
}
public void Delete(int id)
{
_articleTypeService.Remove(id);
}
public ArticleType Get(int id)
{
return _articleTypeService.Get(id);
}
public ArticleType GetByName(string name)
{
return _articleTypeService.GetByUrl(name);
}
public ServiceResult<ArticleType> Update(ArticleType articleType)
{
后面还有 7 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。