Ejemplo n.º 1
0
        public List<Voyage> GetAll()
        {
            var fetchStrategy = new ListFetchStrategy<Voyage>();
            fetchStrategy.Include(v => v.VesselInCompany).Include(v => v.Company);

            return this.voyageRepository.GetAll(fetchStrategy).ToList();
        }
Ejemplo n.º 2
0
        public List<Voyage> GetByFilter(long companyId, long vesselInCompanyId)
        {
            var fetchStrategy = new ListFetchStrategy<Voyage>();
            fetchStrategy.Include(v => v.VesselInCompany).Include(v => v.Company);

            var result = this.voyageRepository.Find(
                v => v.IsActive && v.CompanyId == companyId && v.VesselInCompanyId == vesselInCompanyId, fetchStrategy).ToList();

            return result;
        }
Ejemplo n.º 3
0
        public PageResult<Voyage> GetPagedData(int pageSize, int pageIndex)
        {
            var pageNumber = pageIndex + 1;

            var fetchStrategy = new ListFetchStrategy<Voyage>(nolock: true);
            fetchStrategy.Include(v => v.VesselInCompany).Include(v => v.Company);

            fetchStrategy.WithPaging(pageSize, pageNumber);

            this.voyageRepository.Find(v => v.IsActive, fetchStrategy);

            return fetchStrategy.PageCriteria.PageResult;
        }
Ejemplo n.º 4
0
        public PageResult<VoyageLog> GetPagedDataByFilter(long voyageId, int pageSize, int pageIndex)
        {
            var pageNumber = pageIndex + 1;

            var fetchStrategy = new ListFetchStrategy<VoyageLog>(nolock: true);
            fetchStrategy.Include(v => v.VesselInCompany).Include(v => v.Company);

            fetchStrategy.WithPaging(pageSize, pageNumber);

            this.voyageLogRepository.Find(v => v.ReferencedVoyageId == voyageId, fetchStrategy);

            return fetchStrategy.PageCriteria.PageResult;
        }
Ejemplo n.º 5
0
        public PageResultDto<OrderDto> GetByFilter(int companyId, int orderCreatorId, string orderTypesString, DateTime fromDate, DateTime toDate, int pageSize, int pageIndex, long? supplierId, long? transporterId, bool includeOrderItem, string orderIdListString, string orderCode, bool submitedState)
        {
            _unitOfWorkScope.LazyLoadingEnabled = false;
            _unitOfWorkScope.ProxyCreationEnabled = false;
            var toDateParam = toDate.Date.AddDays(1);
            var fetch =
                new ListFetchStrategy<Order>().Include(o => o.FromVesselInCompany).Include(o => o.ToVesselInCompany).Include(o => o.Supplier).Include(o => o.Receiver).
                    Include(o => o.Transporter).Include(o => o.Owner).Include(o => o.ApproveWorkFlows).Include
                    (o => o.ApproveWorkFlows.Last().CurrentWorkflowStep).Include(o => o.ApproveWorkFlows.Last().CurrentWorkflowStep.ActorUser).
                    WithPaging(pageSize, pageIndex + 1);

            if (includeOrderItem)
                fetch.Include(c => c.OrderItems);

            var orderTypes = new List<OrderTypes>();
            if (!string.IsNullOrEmpty(orderTypesString))
            {
                var orderTypeDtos = orderTypesString.Split(',');
                orderTypes.AddRange(orderTypeDtos.Where(c => c != "0").Select(item => (OrderTypes) int.Parse(item)));
            }
            var orderlist = new List<long>();
            if (!string.IsNullOrEmpty(orderIdListString))
            {
                var orderArray = orderIdListString.Split(',');
                orderlist.AddRange(orderArray.Where(c => c != "0").Select(long.Parse));
                _orderRepository.Find(o => orderlist.Count == 0 || orderlist.Contains(o.Id), fetch);
            }
            else
            {
                _orderRepository.Find
                    (
                        o =>
                            (orderTypes.Count == 0 || orderTypes.Contains(o.OrderType))

                                && (companyId == -1 || o.OwnerId == companyId)
                                && (!submitedState || o.State == States.Submitted)
                                && (fromDate == DateTime.MinValue || o.OrderDate >= fromDate.Date)
                                && (toDate == DateTime.MinValue || o.OrderDate <= toDateParam)
                                && (supplierId == 0 || supplierId == null || o.SupplierId == supplierId)
                                && (transporterId == 0 || transporterId == null || o.TransporterId == transporterId)
                                && (string.IsNullOrEmpty(orderCode) || o.Code == orderCode)
                                , fetch);

            }
            var ordersPageResult = fetch.PageCriteria.PageResult;

            var result = new PageResultDto<OrderDto>
                             {
                                 CurrentPage = ordersPageResult.CurrentPage,
                                 PageSize = ordersPageResult.PageSize,
                                 Result = _orderDtoMapper.MapToModelWithAllIncludes(ordersPageResult.Result).ToList(),
                                 TotalCount = ordersPageResult.TotalCount,
                                 TotalPages = ordersPageResult.TotalPages,
                             };
            return result;
        }
Ejemplo n.º 6
0
        public List<Voyage> GetVoyagesEndedBefore(DateTime dateTime)
        {
            var fetchStrategy = new ListFetchStrategy<Voyage>();
            fetchStrategy.Include(v => v.VesselInCompany).Include(v => v.Company);

            return this.voyageRepository.Find(v => v.EndDate < dateTime && v.IsActive, fetchStrategy).ToList();
        }
        public void UpdateFuelReportDetail_InvalidFuelReportDetailId()
        {
            #region Arrange

            var fetchStategy = new ListFetchStrategy<FuelReport>();
            fetchStategy.Include(fr => fr.FuelReportDetails);

            fetchStategy.OrderByDescending(en => en.Id);

            long validFuelReportId = this.testObjects.FuelReportRepository.GetAll(fetchStategy).First().Id;

            FuelReport validFuelReport = this.testObjects.FuelReportRepository.Find(c => c.Id == validFuelReportId, fetchStategy).FirstOrDefault();

            FuelReportDetail lastFuelReportDetail = validFuelReport.FuelReportDetails.OrderByDescending(frd => frd.Id).FirstOrDefault();

            long invalidFuelReportDetailId = 0L;

            if (lastFuelReportDetail != null)
            {
                invalidFuelReportDetailId = lastFuelReportDetail.Id + 1;
            }

            #endregion

            #region Action

            Exception thrownException = null;

            FuelReportDetail result = null;

            try
            {
                result = this.testObjects.FuelReportApplicationService.UpdateFuelReportDetail(validFuelReportId, invalidFuelReportDetailId, 1, 1, 1, ReceiveTypes.InternalTransfer, 1, TransferTypes.InternalTransfer, 1, CorrectionTypes.Plus, 1, 1, null, null, null);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            #endregion

            #region Assert

            Assert.IsNotNull(thrownException);

            Assert.IsInstanceOfType(thrownException, typeof(ObjectNotFound));

            Assert.AreEqual("FuelReportDetail", ((ObjectNotFound)thrownException).EntityName);

            #endregion
        }