public IEnumerable <Subdivision> GetCashSubdivisionsAvailableForUser(IUnitOfWork uow, UserBase user) { Type[] cashDocumentTypes = { typeof(Income), typeof(Expense), typeof(AdvanceReport) }; var validationResult = EntitySubdivisionForUserPermissionValidator.Validate(uow, user.Id, cashDocumentTypes); var subdivisionsList = new List <Subdivision>(); foreach (var item in cashDocumentTypes) { subdivisionsList.AddRange(validationResult .Where(x => x.GetPermission(item).Read) .Select(x => x.Subdivision) ); } return(subdivisionsList.Distinct()); }
public IEnumerable <Subdivision> GetAvailableSubdivionsForUser(IUnitOfWork uow, Type[] documentsTypes) { var validationResult = EntitySubdivisionForUserPermissionValidator.Validate(uow, documentsTypes); var subdivisionsList = new List <Subdivision>(); foreach (var item in documentsTypes) { subdivisionsList.AddRange(validationResult .Where(x => x.GetPermission(item).Read) .Select(x => x.Subdivision) ); } return(subdivisionsList.Distinct()); }
public void InitSubdivisionsAccess(Type[] types) { var validationResult = EntitySubdivisionForUserPermissionValidator.Validate(UoW, types); var subdivisionsList = new List <Subdivision>(); foreach (var item in types) { subdivisionsList.AddRange(validationResult .Where(x => x.GetPermission(item).Read) .Select(x => x.Subdivision) ); } mainSubdivisions = validationResult.Where(x => x.IsMainSubdivision).Select(x => x.Subdivision); ShowSubdivisions = validationResult.Any(x => !x.IsMainSubdivision) && subdivisionsList.Any(); AllowedSubdivisions = subdivisionsList; }
private bool ValidateAndFillList(Type[] entityTypes) { var validationResult = EntitySubdivisionForUserPermissionValidator.Validate(uow, entityTypes); var subdivisionsList = new List <Subdivision>(); foreach (var item in entityTypes) { subdivisionsList.AddRange(validationResult .Where(x => x.GetPermission(item).Read) .Select(x => x.Subdivision) ); } NeedChooseSubdivision = validationResult.Any(x => !x.IsMainSubdivision) && subdivisionsList.Any(); ShowFilter(); if (!subdivisionsList.Any()) { return(false); } FillList(subdivisionsList); return(true); }