using NFine.Domain.Entity.SystemManage; using NFine.Domain.IRepository.SystemManage; using NFine.Repository.SystemManage; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; namespace NFine.Application.SystemManage { public class ItemsApp { private IItemsRepository service = new ItemsRepository(); public List GetList() { return service.IQueryable().ToList(); } public ItemsEntity GetForm(string keyValue) { return service.FindEntity(keyValue); } public ItemsEntity GetForm2(string keyValue) { Expression> predicate = null; predicate = t => t.F_FullName == keyValue; return service.FindEntity(predicate); } public void DeleteForm(string keyValue) { if (service.IQueryable().Count(t => t.F_ParentId.Equals(keyValue)) > 0) { throw new Exception("删除失败!操作的对象包含了下级数据。"); } else { service.Delete(t => t.F_Id == keyValue); } } public void SubmitForm(ItemsEntity itemsEntity, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { itemsEntity.Modify(keyValue); service.Update(itemsEntity); } else { itemsEntity.Create(); service.Insert(itemsEntity); } } } }