public CashInfoPanelView(IUnitOfWorkFactory uowFactory,
                                 ICashRepository cashRepository,
                                 ISubdivisionRepository subdivisionRepository,
                                 IUserRepository userRepository)
        {
            this.Build();
            _uow            = uowFactory?.CreateWithoutRoot("Боковая панель остатков по кассам") ?? throw new ArgumentNullException(nameof(uowFactory));
            _cashRepository = cashRepository ?? throw new ArgumentNullException(nameof(cashRepository));

            var currentUser           = ServicesConfig.CommonServices.UserService.GetCurrentUser(_uow);
            var availableSubdivisions = subdivisionRepository.GetCashSubdivisionsAvailableForUser(_uow, currentUser).ToList();
            var settings =
                (userRepository ?? throw new ArgumentNullException(nameof(userRepository)))
                .GetCurrentUserSettings(_uow);
            var needSave = settings.UpdateCashSortingSettings(availableSubdivisions);

            if (needSave)
            {
                _uow.Save(settings);
                _uow.Commit();
            }

            _sortedSubdivisionsIds = settings.CashSubdivisionSortingSettings
                                     .OrderBy(x => x.SortingIndex)
                                     .Select(x => x.CashSubdivision.Id)
                                     .ToList();
        }
Пример #2
0
        private List <Subdivision> GetSubdivisionsForUser()
        {
            var availableSubdivisionsForUser = subdivisionRepository.GetCashSubdivisionsAvailableForUser
                                                   (UoW, commonServices.UserService.GetCurrentUser(UoW));

            return(new List <Subdivision>(availableSubdivisionsForUser));
        }
 private void UpdateCashSubdivisions()
 {
     AvailableSubdivisions = subdivisionRepository.GetCashSubdivisionsAvailableForUser(UoW, CurrentUser);
     if (AvailableSubdivisions.Contains(CurrentEmployee.Subdivision))
     {
         Entity.CashSubdivision = CurrentEmployee.Subdivision;
     }
 }
Пример #4
0
 private IEnumerable <Subdivision> GetSubdivisionsForUser() =>
 _subdivisionRepository.GetCashSubdivisionsAvailableForUser(UoW, _commonServices.UserService.GetCurrentUser(UoW));