📄 contentcharge.cs
字号:
namespace PowerEasy.Contents
{
using PowerEasy.Common;
using PowerEasy.IDal.Contents;
using PowerEasy.Model.Contents;
using System;
using System.Collections.Generic;
using System.Text;
public sealed class ContentCharge
{
private static readonly IContentCharge dal = DataAccess.CreateContentCharge();
private ContentCharge()
{
}
public static bool Add(ContentChargeInfo contentChargeInfo)
{
return dal.Add(contentChargeInfo);
}
public static bool BatchUpdate(ContentChargeInfo contentChargeInfo, string itemId, Dictionary<string, bool> checkItem, int batchType)
{
if (!DataValidator.IsValidId(itemId))
{
return false;
}
if (!checkItem.ContainsValue(true))
{
return false;
}
StringBuilder sb = new StringBuilder();
int generalId = 0;
if (batchType != 1)
{
foreach (string str in itemId.Split(new char[] { ',' }))
{
generalId = DataConverter.CLng(str);
if (generalId != 0)
{
if (!dal.Exists(generalId))
{
contentChargeInfo.GeneralId = generalId;
dal.Add(contentChargeInfo);
}
else
{
StringHelper.AppendString(sb, str);
}
}
}
}
else
{
foreach (CommonModelInfo info in ContentManage.GetCommonModelInfoList(itemId))
{
if (!dal.Exists(info.GeneralId))
{
contentChargeInfo.GeneralId = info.GeneralId;
dal.Add(contentChargeInfo);
continue;
}
StringHelper.AppendString(sb, info.GeneralId.ToString());
}
}
if (sb.Length > 0)
{
return dal.BatchUpdate(contentChargeInfo, sb.ToString(), checkItem);
}
return true;
}
public static void Delete(int generalId)
{
dal.Delete(generalId);
}
public static void Delete(string generalId)
{
if (DataValidator.IsValidId(generalId))
{
dal.Delete(generalId);
}
}
public static bool Exists(int generalId)
{
return dal.Exists(generalId);
}
public static ContentChargeInfo GetContentChargeInfoById(int generalId)
{
return dal.GetContentChargeInfoById(generalId);
}
public static bool Update(ContentChargeInfo contentChargeInfo)
{
return dal.Update(contentChargeInfo);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -