Пример #1
0
        public IList <GoodsInRouteListResultWithSpecialRequirements> GetGoodsAndEquipsInRLWithSpecialRequirements(
            IUnitOfWork uow,
            RouteList routeList,
            ISubdivisionRepository subdivisionRepository = null,
            Warehouse warehouse = null)
        {
            if (subdivisionRepository == null && warehouse != null)
            {
                throw new ArgumentNullException(nameof(subdivisionRepository));
            }

            List <GoodsInRouteListResultWithSpecialRequirements> result = new List <GoodsInRouteListResultWithSpecialRequirements>();

            GoodsInRouteListResultWithSpecialRequirements terminal = null;

            if (warehouse != null)
            {
                var cashSubdivisions = subdivisionRepository.GetCashSubdivisions(uow);
                if (cashSubdivisions.Contains(warehouse.OwningSubdivision))
                {
                    terminal = GetTerminalInRLWithSpecialRequirements(uow, routeList, warehouse);
                }
                else
                {
                    result.AddRange(GetGoodsInRLWithoutEquipmentsWithSpecialRequirements(uow, routeList).ToList());
                    result.AddRange(GetEquipmentsInRLWithSpecialRequirements(uow, routeList).ToList());
                }
            }
            else
            {
                result.AddRange(GetGoodsInRLWithoutEquipmentsWithSpecialRequirements(uow, routeList).ToList());
                result.AddRange(GetEquipmentsInRLWithSpecialRequirements(uow, routeList).ToList());

                terminal = GetTerminalInRLWithSpecialRequirements(uow, routeList);
            }

            if (terminal != null)
            {
                result.Add(terminal);
            }

            return(result
                   .GroupBy(x => new
            {
                x.NomenclatureId,
                x.ExpireDatePercent,
                x.OwnType
            }
                            ).Select(list => new GoodsInRouteListResultWithSpecialRequirements()
            {
                NomenclatureName = list.FirstOrDefault().NomenclatureName,
                NomenclatureId = list.Key.NomenclatureId,
                OwnType = list.Key.OwnType,
                ExpireDatePercent = list.Key.ExpireDatePercent,
                Amount = list.Sum(x => x.Amount)
            }
                                     ).ToList());
        }
Пример #2
0
        public IList <GoodsInRouteListResult> GetGoodsAndEquipsInRL(
            IUnitOfWork uow,
            RouteList routeList,
            ISubdivisionRepository subdivisionRepository = null,
            Warehouse warehouse = null)
        {
            if (subdivisionRepository == null && warehouse != null)
            {
                throw new ArgumentNullException(nameof(subdivisionRepository));
            }

            List <GoodsInRouteListResult> result = new List <GoodsInRouteListResult>();

            if (warehouse != null)
            {
                var cashSubdivisions = subdivisionRepository.GetCashSubdivisions(uow);
                if (cashSubdivisions.Contains(warehouse.OwningSubdivision))
                {
                    var terminal = GetTerminalInRL(uow, routeList, warehouse);
                    if (terminal != null)
                    {
                        result.Add(terminal);
                    }
                }
                else
                {
                    result.AddRange(GetGoodsInRLWithoutEquipments(uow, routeList).ToList());
                    result.AddRange(GetEquipmentsInRL(uow, routeList).ToList());
                }
            }
            else
            {
                result.AddRange(GetGoodsInRLWithoutEquipments(uow, routeList).ToList());
                result.AddRange(GetEquipmentsInRL(uow, routeList).ToList());

                var terminal = GetTerminalInRL(uow, routeList);
                if (terminal != null)
                {
                    result.Add(terminal);
                }
            }

            return(result
                   .GroupBy(x => x.NomenclatureId, x => x.Amount)
                   .Select(x => new GoodsInRouteListResult {
                NomenclatureId = x.Key,
                Amount = x.Sum()
            }
                           )
                   .ToList());
        }
Пример #3
0
 public bool HasAccessToClosingRoutelist(IUnitOfWork uow, ISubdivisionRepository subdivisionRepository, IEmployeeRepository employeeRepository, IUserService userService)
 {
     return(userService.GetCurrentUser(uow).IsAdmin ||
            subdivisionRepository.GetCashSubdivisions(uow).Contains(employeeRepository.GetEmployeeForCurrentUser(uow).Subdivision));
 }