public ActionResult AddReader(Guid id) { ViewBag.DocumentId = id; var empls = _EmplService.GetPartialIntercompanyView(x => x.ApplicationUserId != null); foreach (var empl in empls) { if (_DocumentReaderService.Contains(x => x.DocumentTableId == id && x.UserId == empl.ApplicationUserId)) { empl.isActiveDualList = true; } } return(View(empls)); }
public bool isShowDocument(Guid documentId, Guid ProcessId, string currentUserName = "", bool isAfterView = false) { string localUserName = getCurrentUserName(currentUserName); IEnumerable <WFTrackerTable> trackerTables = null; if (isAfterView == false) { trackerTables = _WorkflowTrackerService.GetCurrentStep(x => x.DocumentTableId == documentId && x.SignUserId == null); } else { trackerTables = _WorkflowTrackerService.GetPartial(x => x.DocumentTableId == documentId); } DocumentTable documentTable = Find(documentId); ApplicationUser user = _AccountService.FirstOrDefault(x => x.UserName == localUserName); if (user.Id == documentTable.ApplicationUserCreatedId) { return(true); } if (checkTrackUsers(trackerTables, user.Id)) { return(true); } ApplicationDbContext context = new ApplicationDbContext(); UserManager <ApplicationUser> UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context)); if (UserManager.IsInRole(user.Id, "Administrator")) { return(true); } var delegationItems = _DelegationService.GetPartial(x => x.EmplTableTo.ApplicationUserId == user.Id && x.DateFrom <= DateTime.UtcNow && x.DateTo >= DateTime.UtcNow && x.isArchive == false && x.CompanyTableId == user.CompanyTableId); foreach (var delegationItem in delegationItems) { if (delegationItem.GroupProcessTableId != null || delegationItem.ProcessTableId != null) { if (delegationItem.ProcessTableId == ProcessId) { if (checkTrackUsers(trackerTables, delegationItem.EmplTableFrom.ApplicationUserId)) { return(true); } } else if (_ProcessService.Find(ProcessId).GroupProcessTableId == delegationItem.GroupProcessTableId) { if (checkTrackUsers(trackerTables, delegationItem.EmplTableFrom.ApplicationUserId)) { return(true); } } } else { if (checkTrackUsers(trackerTables, delegationItem.EmplTableFrom.ApplicationUserId)) { return(true); } } } if (_DocumentReaderService.Contains(x => x.DocumentTableId == documentId && x.UserId == user.Id)) { return(true); } return(false); }