Пример #1
0
        public void Test_List()
        {
            const long clientId = 1;
            var        data     = _context.CreateMany <ApplicationData>().ToArray();
            var        cargoReceivedDaysToShow = _context.Create <int>();
            var        cargoReceivedStateId    = _context.Create <int>();

            _context.StateFilter.Setup(x => x.GetStateVisibility()).Returns(_stateIds);
            _context.ApplicationListItemMapper.Setup(x => x.Map(data, TwoLetterISOLanguageName.English)).Returns(_models);
            _context.StateConfig.Setup(x => x.CargoReceivedDaysToShow).Returns(cargoReceivedDaysToShow);
            _context.StateConfig.Setup(x => x.CargoReceivedStateId).Returns(cargoReceivedStateId);
            _context.ApplicationGrouper.Setup(x => x.Group(_models, new[] { OrderType.State }, clientId, null, null, null))
            .Returns(new ApplicationGroup[0]);
            _context.ApplicationRepository.Setup(
                x => x.Count(_stateIds, clientId, null, null, null, cargoReceivedStateId, cargoReceivedDaysToShow, null))
            .Returns(It.IsAny <long>());
            _context.ApplicationRepository.Setup(x =>
                                                 x.List(_stateIds, _orders, 0, 0, clientId, null, null, null, cargoReceivedStateId, cargoReceivedDaysToShow, null))
            .Returns(data);

            var collection = _service.List(TwoLetterISOLanguageName.English, 0, 0, _orders, clientId);

            collection.Data.Should().BeNull();
            collection.Groups.Should().NotBeNull();
            _context.StateFilter.Verify(x => x.GetStateVisibility(), Times.Once());
            _context.ApplicationListItemMapper.Verify(x => x.Map(data, TwoLetterISOLanguageName.English));
            _context.ApplicationGrouper.Verify(x => x.Group(_models, new[] { OrderType.State }, clientId, null, null, null),
                                               Times.Once());
            _context.ApplicationRepository.Verify(
                x => x.Count(_stateIds, clientId, null, null, null, cargoReceivedStateId, cargoReceivedDaysToShow, null),
                Times.Once());
            _context.ApplicationRepository.Verify(x =>
                                                  x.List(_stateIds, _orders, 0, 0, clientId, null, null, null, cargoReceivedStateId, cargoReceivedDaysToShow, null),
                                                  Times.Once());
        }
Пример #2
0
        public virtual JsonResult List(int take, int skip, Dictionary <string, string>[] group)
        {
            var orders = OrderHelper.Get(group);

            var forwarderId = _forwarders.GetByUserId(_identity.Id);

            Debug.Assert(forwarderId != null);

            var data = _presenter.List(_identity.Language, take, skip, orders, null, null, forwarderId.Value);

            _forwarderApplication.UpdateDeliveryData(
                data.Groups.SelectMany(x => x.items).Cast <ApplicationListItem>().ToArray(),
                _identity.Language);

            return(Json(data));
        }
Пример #3
0
        public virtual JsonResult List(int take, int skip, Dictionary <string, string>[] group)
        {
            var orders = OrderHelper.Get(group);

            var senderId = _senders.GetByUserId(_identity.Id);

            var forwarderId = _forwarders.GetByUserId(_identity.Id);

            var client = _clients.GetByUserId(_identity.Id);

            var carrierId = _carriers.GetByUserId(_identity.Id);

            var clientId = client != null
                                ? client.ClientId
                                : (long?)null;

            var data = _presenter.List(_identity.Language, take, skip, orders, clientId, senderId, forwarderId, carrierId);

            var result = Json(data);

            result.MaxJsonLength = int.MaxValue;

            return(result);
        }