DutysApplicationService.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using System.Web.Mvc;
  4. using Abp.Application.Services.Dto;
  5. using Abp.Authorization;
  6. using Abp.Domain.Repositories;
  7. using IwbZero.AppServiceBase;
  8. using ShwasherSys.Authorization.Permissions;
  9. using ShwasherSys.BasicInfo.Dutys.Dto;
  10. namespace ShwasherSys.BasicInfo.Dutys
  11. {
  12. [AbpAuthorize]
  13. public class DutysAppService : ShwasherAsyncCrudAppService<Duty, DutyDto, int, PagedRequestDto, DutyCreateDto, DutyUpdateDto >, IDutysAppService
  14. {
  15. public DutysAppService(IRepository<Duty, int> repository) : base(repository)
  16. {
  17. }
  18. protected override string GetPermissionName { get; set; } = PermissionNames.PagesBasicInfoDutys;
  19. protected override string GetAllPermissionName { get; set; } = PermissionNames.PagesBasicInfoDutys;
  20. protected override string CreatePermissionName { get; set; } = PermissionNames.PagesBasicInfoDutysCreate;
  21. protected override string UpdatePermissionName { get; set; } = PermissionNames.PagesBasicInfoDutysUpdate;
  22. protected override string DeletePermissionName { get; set; } = PermissionNames.PagesBasicInfoDutysDelete;
  23. public override async Task Delete(EntityDto<int> input)
  24. {
  25. CheckDeletePermission();
  26. var entity = await Repository.FirstOrDefaultAsync(a => a.Id == input.Id);
  27. /*if ((await Repository.GetAllListAsync(a => a.FatherRegionID == entity.Id && a.IsLock == "N")).Any())
  28. {
  29. CheckErrors(IwbIdentityResult.Failed("此菜单下还有子区域,不能删除"));
  30. }*/
  31. entity.IsLock = "Y";
  32. // await Repository.UpdateAsync(entity);
  33. await CurrentUnitOfWork.SaveChangesAsync();
  34. }
  35. public List<SelectListItem> GetDutysSelects()
  36. {
  37. var slist = new List<SelectListItem>();
  38. var list = Repository.GetAll();
  39. foreach (var l in list)
  40. {
  41. slist.Add(new SelectListItem { Text = l.DutyName, Value = l.Id+"" });
  42. }
  43. return slist;
  44. }
  45. }
  46. }