纽威
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.6 KiB

3 years ago
  1. using NFine.Domain.Entity.SystemManage;
  2. using NFine.Domain.IRepository.SystemManage;
  3. using NFine.Repository.SystemManage;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Linq.Expressions;
  8. namespace NFine.Application.SystemManage
  9. {
  10. public class ItemsApp
  11. {
  12. private IItemsRepository service = new ItemsRepository();
  13. public List<ItemsEntity> GetList()
  14. {
  15. return service.IQueryable().ToList();
  16. }
  17. public ItemsEntity GetForm(string keyValue)
  18. {
  19. return service.FindEntity(keyValue);
  20. }
  21. public ItemsEntity GetForm2(string keyValue)
  22. {
  23. Expression<Func<ItemsEntity, bool>> predicate = null;
  24. predicate = t => t.F_FullName == keyValue;
  25. return service.FindEntity(predicate);
  26. }
  27. public void DeleteForm(string keyValue)
  28. {
  29. if (service.IQueryable().Count(t => t.F_ParentId.Equals(keyValue)) > 0)
  30. {
  31. throw new Exception("删除失败!操作的对象包含了下级数据。");
  32. }
  33. else
  34. {
  35. service.Delete(t => t.F_Id == keyValue);
  36. }
  37. }
  38. public void SubmitForm(ItemsEntity itemsEntity, string keyValue)
  39. {
  40. if (!string.IsNullOrEmpty(keyValue))
  41. {
  42. itemsEntity.Modify(keyValue);
  43. service.Update(itemsEntity);
  44. }
  45. else
  46. {
  47. itemsEntity.Create();
  48. service.Insert(itemsEntity);
  49. }
  50. }
  51. }
  52. }