Ejemplo n.º 1
0
        public PageResultDTO <UserDTOWithActions> GetAllUsers(int pageSize, int pageIndex, string filter)
        {
            var fs = new ListFetchStrategy <User>(Enums.FetchInUnitOfWorkOption.NoTracking);

            fs.WithPaging(pageSize, pageIndex);

            var criterias = filter.Split(';');
            var predicate = getUserPredicate(criterias);
            var rs        = getPredicate(criterias);

            if (criterias.Count() > 1)
            {
                //TODO:
                userRep.FindUsers(predicate, fs);//, rs[0], rs[1], rs[2], pageSize, pageIndex);
            }
            else
            {
                //TODO:
                userRep.FindUsers(predicate, fs);//, "", "", "", pageSize, pageIndex);
            }
            var res = new PageResultDTO <UserDTOWithActions>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            List <UserDTOWithActions> result = new List <UserDTOWithActions>();

            fs.PageCriteria.PageResult.Result.ForEach(p =>
            {
                var u = userDTOWithActionsMapper.MapToModel(p);
                //u.CompanyDto = new CompanyDto() { Id = p.CompanyId };
                result.Add(u);
            });
            res.Result = result;
            return(res);
        }
Ejemplo n.º 2
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.º 3
0
 public void FindUsers(Expression <Func <User, bool> > predicate, ListFetchStrategy <User> fs)
 {
     //var a=rep.GetQuery<User>().Where(predicate);
     //a.ToList();
     repUser.Find <User>(predicate, fs);
     // rep.GetAll<User>(fs);
 }
Ejemplo n.º 4
0
        public PageResultDTO <JobIndexPointSummaryDTOWithAction> GetAllJobIndexPoints(long periodId, long calculationId, int pageSize, int pageIndex)
        {
            var fs  = new ListFetchStrategy <JobIndexPointWithEmployee>(Enums.FetchInUnitOfWorkOption.NoTracking);
            var cal = calculationRep.GetById(new CalculationId(calculationId));

            if (cal.PeriodId.Id != periodId)
            {
                throw new Exception("چنین محاسبه ای در دوره ذکر شده نداریم.");
            }
            fs.WithPaging(pageSize, pageIndex).OrderByDescending(c => c.JobIndexPoint.Value);

            repository.Find <SummaryEmployeePoint>(c => c.CalculationId == cal.Id && c.IsFinal, fs);

            var res = new PageResultDTO <JobIndexPointSummaryDTOWithAction>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            var i   = (res.CurrentPage - 1) * res.PageSize;
            var lst = fs.PageCriteria.PageResult.Result.Select(p =>
            {
                i++;
                var m = jobIndexPointMapper.MapToModel(p);
                m.EmployeeRankInPeriod = i;
                return(m);
            }).ToList();

            res.Result = lst;
            return(res);
        }
Ejemplo n.º 5
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;
        }
        public CharterOut GetCharterOutStart(Company company, VesselInCompany vesselInCompany, DateTime date)
        {
            IListFetchStrategy<Charter> fetchStrategy = new ListFetchStrategy<Charter>()
                .Include(c => c.CharterItems).OrderBy(c => c.ActionDate);

            var foundCharterOut = charterOutRepository
                .Find(cho => cho.CharterType == CharterType.Start && date >= cho.ActionDate &&
                    cho.OwnerId == company.Id && cho.VesselInCompanyId == vesselInCompany.Id, fetchStrategy).LastOrDefault() as CharterOut;

            return foundCharterOut;
        }
Ejemplo n.º 7
0
 public void FindBy(EntityTypeEnum entityId, ListFetchStrategy <CustomFieldType> fs)
 {
     if (entityId == null)
     {
         rep.GetAll(fs);
     }
     else
     {
         rep.Find(c => Equals(c.EntityId, entityId), fs);
     }
 }
Ejemplo n.º 8
0
 public void GetAll(EntityTypeEnum entityType, ListFetchStrategy <CustomFieldType> fs)
 {
     if (entityType == null)
     {
         rep.GetAll(fs);
     }
     else
     {
         rep.Find(c => c.EntityId == entityType, fs);
     }
 }
Ejemplo n.º 9
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.º 10
0
        public PageResultDTO <PolicyDTOWithActions> GetAllPolicies(int pageSize, int pageIndex)
        {
            var fs = new ListFetchStrategy <Policy>(Enums.FetchInUnitOfWorkOption.NoTracking);

            fs.OrderBy(x => x.Id);
            fs.WithPaging(pageSize, pageIndex);
            policyRep.FindBy(fs);
            var res = new PageResultDTO <PolicyDTOWithActions>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            res.Result = fs.PageCriteria.PageResult.Result.Select(r => policyWithActionMapper.MapToModel(r)).ToList();
            return(res);
        }
Ejemplo n.º 11
0
        public PageResultDTO <PeriodDTOWithAction> GetAllPeriods(int pageSize, int pageIndex)
        {
            var fs = new ListFetchStrategy <Period>(Enums.FetchInUnitOfWorkOption.NoTracking);

            fs.WithPaging(pageSize, pageIndex);
            periodRep.GetAll(fs);
            var res = new PageResultDTO <PeriodDTOWithAction>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            res.Result =
                fs.PageCriteria.PageResult.Result.Select(p => periodDTOWithActionsMapper.MapToModel(p)).ToList();
            return(res);
        }
Ejemplo n.º 12
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.º 13
0
        public PageResultDTO <EmployeeDTOWithActions> GetAllEmployees(long periodId, int pageSize, int pageIndex)
        {
            var fs = new ListFetchStrategy <Employee>(Enums.FetchInUnitOfWorkOption.NoTracking);

            fs.WithPaging(pageSize, pageIndex);
            fs.OrderBy(e => e.Id);
            employeeRep.Find(e => e.Id.PeriodId == new PeriodId(periodId), fs);
            var res = new PageResultDTO <EmployeeDTOWithActions>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            res.Result =
                fs.PageCriteria.PageResult.Result.Select(p => employeeDTOWithActionsMapper.MapToModel(p)).ToList();
            return(res);
        }
Ejemplo n.º 14
0
        public PageResultDTO <CalculationBriefDTOWithAction> GetAllCalculations(long periodId, int pageSize, int pageIndex)
        {
            var fs = new ListFetchStrategy <CalculationWithPolicyAndPeriod>(Enums.FetchInUnitOfWorkOption.NoTracking);

            fs.WithPaging(pageSize, pageIndex).OrderBy(c => c.Calculation.Id.Id);
            var x = calculationRep.FindByWithPolicy(new PeriodId(periodId), fs);

            var res = new PageResultDTO <CalculationBriefDTOWithAction>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            var lst = fs.PageCriteria.PageResult.Result.Select(p => calculationBriefMapper.MapToModel(p)).ToList();

            res.Result = lst;
            return(res);
        }
Ejemplo n.º 15
0
        public PageResultDTO <CalculationExceptionBriefDTOWithAction> GetAllCalculationExceptions(long calculationId, int pageSize, int pageIndex)
        {
            var fs = new ListFetchStrategy <EmployeeCalculationException>(Enums.FetchInUnitOfWorkOption.NoTracking);

            fs.WithPaging(pageSize, pageIndex).OrderByDescending(c => c.Id.Id);
            var x = calculationExpRepository.FindBy(new CalculationId(calculationId), fs);

            var res = new PageResultDTO <CalculationExceptionBriefDTOWithAction>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            var lst = fs.PageCriteria.PageResult.Result.Select(p => calculationExceptionBriefMapper.MapToModel(p)).ToList();

            res.Result = lst;

            return(res);
        }
Ejemplo n.º 16
0
        public PageResultDTO <EmployeeDTOWithActions> GetAllEmployees(long periodId, int pageSize, int pageIndex,
                                                                      string filter)
        {
            var fs = new ListFetchStrategy <Employee>(Enums.FetchInUnitOfWorkOption.NoTracking);

            fs.WithPaging(pageSize, pageIndex);
            fs.OrderBy(e => e.Id);
            //todo:(LOW) Must be code in better way
            var criterias = filter.Split(';');
            var predicate = getEmployeePredicate(criterias, periodId);

            employeeRep.Find(predicate, fs);
            var res = new PageResultDTO <EmployeeDTOWithActions>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            res.Result =
                fs.PageCriteria.PageResult.Result.Select(p => employeeDTOWithActionsMapper.MapToModel(p)).ToList();
            return(res);
        }
Ejemplo n.º 17
0
        public List<UserDto> GetAll(int pageSize, int pageIndex)
        {
            var fetch = new ListFetchStrategy<FuelUser>().WithPaging(pageSize, pageIndex );

            _userRepository.GetAll(fetch);

            var finalResult = new PageResultDto<UserDto>
                                  {
                                      CurrentPage = pageIndex,
                                      PageSize = pageSize,
                                      Result = _mapper.MapToModel(fetch.PageCriteria.PageResult.Result).ToList(),
                                      TotalCount = fetch.PageCriteria.PageResult.TotalCount,
                                      TotalPages = fetch.PageCriteria.PageResult.TotalPages
                                  };

            foreach (var user in finalResult.Result)
                user.Code = user.FirstName;

            return finalResult.Result.ToList();
        }
Ejemplo n.º 18
0
        public PageResult<CharterOut> GetByFilter(long companyId, int pageSize, int pageIndex)
        {
            var res = new PageResult<CharterOut>();

            var strategy = new ListFetchStrategy<Charter>(Enums.FetchInUnitOfWorkOption.NoTracking);

            IQueryable<CharterOut> query = this.GetAll(strategy).OfType<CharterOut>().OrderBy(p => p.Id)
                .Where(c => c.OwnerId == companyId && c.CharterType == CharterType.Start).AsQueryable();

            res.Result = query.Skip(pageSize * (pageIndex - 1))
                .Take(pageSize).ToList();

            res.TotalCount = query.Count();

            res.TotalPages = Convert.ToInt32(Math.Ceiling(decimal.Divide(res.TotalCount, pageSize)));

            res.CurrentPage = pageIndex + 1;

            return res;
        }
Ejemplo n.º 19
0
        public PageResultDTO <ClaimDTOWithAction> GetClaimsWithActions(long periodId, string employeeNo, int pageSize, int pageIndex, QueryStringConditions queryStringConditions)
        {
            var fs     = new ListFetchStrategy <Claim>(Enums.FetchInUnitOfWorkOption.NoTracking);
            var sortBy = QueryConditionHelper.GetSortByDictionary(queryStringConditions.SortBy);

            foreach (var item in sortBy)
            {
                fs.SortCriterias.Add(new StringSortCriteria <Claim>(item.Key,
                                                                    (item.Value.ToUpper() == "ASC")
                                                                                 ? Enums.SortOrder.Ascending
                                                                               : Enums.SortOrder.Descending));
            }
            fs.OrderBy(x => x.Id);
            fs.WithPaging(pageSize, pageIndex);
            claimRep.FindBy(fs, employeeNo, new PeriodId(periodId));
            var res = new PageResultDTO <ClaimDTOWithAction>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            res.Result = fs.PageCriteria.PageResult.Result.Select(r => claimDTOWithActionsMapper.MapToModel(r)).ToList();
            return(res);
        }
Ejemplo n.º 20
0
        public PageResultDTO <AbstractUnitIndexDTOWithActions> GetAllUnitIndexCategoriesWithPagination(int pageSize, int pageIndex, QueryStringConditions queryStringConditions)
        {
            var fs     = new ListFetchStrategy <UnitIndexCategory>(Enums.FetchInUnitOfWorkOption.NoTracking);
            var sortBy = QueryConditionHelper.GetSortByDictionary(queryStringConditions.SortBy);

            foreach (var item in sortBy)
            {
                fs.SortCriterias.Add(new StringSortCriteria <UnitIndexCategory>(item.Key,
                                                                                (item.Value.ToUpper() == "ASC")
                                                                                 ? Enums.SortOrder.Ascending
                                                                               : Enums.SortOrder.Descending));
            }
            fs.OrderBy(x => x.Id);
            fs.WithPaging(pageSize, pageIndex);
            unitIndexRep.GetAllUnitIndexCategory(fs);
            var res = new PageResultDTO <AbstractUnitIndexDTOWithActions>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            res.Result = fs.PageCriteria.PageResult.Result.Select(r => unitIndexWithActionsMapper.MapToModel(r));
            return(res);
        }
Ejemplo n.º 21
0
        public PageResultDTO <JobInPeriodDTOWithActions> GetAllJobs(long periodId, int pageSize, int pageIndex, QueryStringConditions queryStringConditions, string selectedColumns)
        {
            var fs     = new ListFetchStrategy <Job>(Enums.FetchInUnitOfWorkOption.NoTracking);
            var sortBy = QueryConditionHelper.GetSortByDictionary(queryStringConditions.SortBy);

            foreach (var item in sortBy)
            {
                fs.SortCriterias.Add(new StringSortCriteria <Job>(item.Key,
                                                                  (item.Value.ToUpper() == "ASC")
                                                                                 ? Enums.SortOrder.Ascending
                                                                               : Enums.SortOrder.Descending));
            }
            fs.OrderBy(x => x.Id);
            fs.WithPaging(pageSize, pageIndex);
            jobRep.Find(e => e.Id.PeriodId == new PeriodId(periodId), fs);
            var res = new PageResultDTO <JobInPeriodDTOWithActions>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            res.Result = fs.PageCriteria.PageResult.Result.Select(r => jobInPeriodDTOWithActionsMapper.MapToModel(r, selectedColumns.Split(','))).ToList();
            return(res);
        }
Ejemplo n.º 22
0
 public void AddUpdateEmployeeTest()
 {
     using (var session = PMSSession.GetSession())
         using (session.BeginTransaction())
         {
             var period   = session.Query <Period>().First();
             var employee = new Employee(Guid.NewGuid().ToString(), period,
                                         Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
             SharedEmployeeCustomField sharedEmployeeCustomField;
             using (var adminSession = PMSAdminSession.GetSession())
                 using (adminSession.BeginTransaction())
                 {
                     var employeeCustomFielType = adminSession.Query <CustomFieldType>().First();
                     sharedEmployeeCustomField =
                         new SharedEmployeeCustomField(new SharedEmployeeCustomFieldId(employeeCustomFielType.Id.Id),
                                                       Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 1, 1);
                 }
             employee.AssignCustomFieldAndValue(sharedEmployeeCustomField, "30");
             session.Save(employee);
             session.Transaction.Commit();
             using (session.BeginTransaction())
             {
                 var rep = new EmployeeRepository(new NHUnitOfWork(session));
                 var fs  = new ListFetchStrategy <Employee>(Enums.FetchInUnitOfWorkOption.NoTracking);
                 fs.WithPaging(10, 1);
                 fs.OrderBy(c => c.Id);
                 rep.Find(e => e.Id.PeriodId == new PeriodId(1), fs);
                 var newEmployee =
                     session.Query <Employee>()
                     .FirstOrDefault(
                         e => e.Id.EmployeeNo == employee.Id.EmployeeNo && e.Id.PeriodId == employee.Id.PeriodId);
                 newEmployee.Update("ehsan", "mohammadi");
                 session.Update(newEmployee);
                 session.Transaction.Commit();
             }
         }
 }
Ejemplo n.º 23
0
        public PageResultDTO <CustomFieldDTOWithActions> GetAllCustomFieldes(int pageSize, int pageIndex, QueryStringConditions queryStringConditions)
        {
            var fs     = new ListFetchStrategy <CustomFieldType>(Enums.FetchInUnitOfWorkOption.NoTracking);
            var sortBy = QueryConditionHelper.GetSortByDictionary(queryStringConditions.SortBy);

            foreach (var item in sortBy)
            {
                fs.SortCriterias.Add(new StringSortCriteria <CustomFieldType>(item.Key,
                                                                              (item.Value.ToUpper() == "ASC")
                                                                                 ? Enums.SortOrder.Ascending
                                                                               : Enums.SortOrder.Descending));
            }
            fs.OrderBy(x => x.Id);
            fs.WithPaging(pageSize, pageIndex);
            var entityId = getEntityIdFromQueryString(queryStringConditions.Filter);

            customFieldRep.GetAll(
                entityId != null ? Enumeration.FromValue <EntityTypeEnum>(entityId.ToString()) : null, fs);
            var res = new PageResultDTO <CustomFieldDTOWithActions>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            res.Result = fs.PageCriteria.PageResult.Result.Select(r => customFieldWithActionMapper.MapToModel(r)).ToList();
            return(res);
        }
Ejemplo n.º 24
0
        public JobIndexPointSummaryDTOWithAction GetEmployeeSummaryCalculationResult(long periodId, long calculationId, string employeeNo)
        {
            var fs = new ListFetchStrategy <JobIndexPointWithEmployee>(Enums.FetchInUnitOfWorkOption.NoTracking);

            var cal = calculationRep.GetById(new CalculationId(calculationId));

            if (cal.PeriodId.Id != periodId)
            {
                throw new Exception("چنین محاسبه ای در دوره ذکر شده نداریم.");
            }
            var empId = new EmployeeId(employeeNo, new PeriodId(periodId));

            fs.WithPaging(1, 0).OrderByDescending(c => c.JobIndexPoint.Value);

            repository.Find <SummaryEmployeePoint>(c => c.CalculationId == cal.Id && c.IsFinal && c.EmployeeId.EmployeeNo == empId.EmployeeNo
                                                   , fs);
            if (!fs.PageCriteria.PageResult.Result.Any())
            {
                throw new JobIndexPointException((int)ApiExceptionCode.DoesNotExistEvaluationForEmployee, ApiExceptionCode.DoesNotExistEvaluationForEmployee.DisplayName);
            }
            var sumaryPoints = fs.PageCriteria.PageResult.Result.Single();

            return(jobIndexPointMapper.MapToModel(sumaryPoints));
        }
Ejemplo n.º 25
0
        public PageResultDTO <EmployeeDTOWithActions> GetSubordinateEmployees(long periodId, string verifierEmployeeNo, int pageSize, int pageIndex,
                                                                              string filter)
        {
            var fs = new ListFetchStrategy <Employee>(Enums.FetchInUnitOfWorkOption.NoTracking);

            fs.WithPaging(pageSize, pageIndex);
            fs.OrderBy(e => e.LastName);
            //todo:(LOW) Must be code in better way
            var criterias = filter.Split(';');
            var predicate = getEmployeePredicate(criterias, periodId);

            employeeRep.GetSubordinatesEmployee(new EmployeeId(verifierEmployeeNo, new PeriodId(periodId)), predicate, fs);
            var res = new PageResultDTO <EmployeeDTOWithActions>();

            res.InjectFrom(fs.PageCriteria.PageResult);
            res.Result =
                fs.PageCriteria.PageResult.Result.Select(p =>
            {
                var mapped = new EmployeeDTOWithActions
                {
                    FirstName   = p.FirstName,
                    LastName    = p.LastName,
                    PeriodId    = p.Id.PeriodId.Id,
                    PersonnelNo = p.Id.EmployeeNo,
                    FinalPoint  = p.FinalPoint,
                    SystemPoint = p.CalculatedPoint,
                    StateName   = p.EmployeePointState.Description,
                    ActionCodes = new List <int>
                    {
                        (int)ActionType.ChangeEmployeePoint,
                    }
                };
                return(mapped);
            }).ToList();
            return(res);
        }
Ejemplo n.º 26
0
 public void Find(Expression <Func <InquiryJobIndexPoint, bool> > predicate, ListFetchStrategy <InquiryJobIndexPoint> fs)
 {
     rep.Find(predicate, fs);
 }
Ejemplo n.º 27
0
        //================================================================================
        public PageResult<Scrap> GetPagedData(int pageSize, int pageIndex)
        {
            var pageNumber = pageIndex + 1;

            var fetchStrategy = new ListFetchStrategy<Scrap>(nolock: true)
                .Include(s => s.VesselInCompany).Include(s => s.SecondParty)
                .WithPaging(pageSize, pageNumber);

            scrapRepository.GetAll(fetchStrategy);

            return fetchStrategy.PageCriteria.PageResult;
        }
Ejemplo n.º 28
0
 public IList <JobIndexCategory> GetAllJobIndexCategory(ListFetchStrategy <JobIndexCategory> fs)
 {
     return(rep.GetAll <JobIndexCategory>(fs));
 }
Ejemplo n.º 29
0
        //================================================================================
        public PageResult<Scrap> GetPagedDataByFilter(long? companyId, DateTime? fromDate, DateTime? toDate, int pageSize, int pageIndex)
        {
            var pageNumber = pageIndex + 1;

            var fetchStrategy = new ListFetchStrategy<Scrap>(nolock: true)
                .Include(s => s.VesselInCompany).Include(s => s.SecondParty)
                .WithPaging(pageSize, pageNumber);

            scrapRepository.Find(
                e => (!companyId.HasValue || e.VesselInCompany.Company.Id == companyId) &&
                    (!fromDate.HasValue || e.ScrapDate >= fromDate) &&
                    (!toDate.HasValue || e.ScrapDate <= toDate),
                fetchStrategy);

            return fetchStrategy.PageCriteria.PageResult;
        }
Ejemplo n.º 30
0
        // todo: input parameters must be converted to IPageCritera
        public PageResultDto<OrderDto> GetAll(int pageSize, int pageIndex)
        {
            var fetch = new ListFetchStrategy<Order>().WithPaging(pageSize, pageIndex);
            _orderRepository.GetAll(fetch);

            var finalResult = new PageResultDto<OrderDto>
                                  {
                                      CurrentPage = pageIndex,
                                      PageSize = pageSize,
                                      Result = _orderDtoMapper.MapToModel(fetch.PageCriteria.PageResult.Result.ToList()).ToList(),
                                      TotalCount = fetch.PageCriteria.PageResult.TotalCount,
                                      TotalPages = fetch.PageCriteria.PageResult.TotalPages
                                  };

            return finalResult;
        }
Ejemplo n.º 31
0
        //================================================================================
        public List<FuelReport> GetPreviousNotFinalApprovedReports(FuelReport fuelReport)
        {
            var fetchStrategy = new ListFetchStrategy<FuelReport>().OrderBy(c => c.EventDate);

            var result = this.fuelReportRepository.Find(
                                    Extensions.And(this.isFuelReportInFinalApprovedState.Not().Predicate, Extensions.And(this.isFuelReportOperational.Predicate, f => f.EventDate < fuelReport.EventDate)));

            return result.ToList();
        }
Ejemplo n.º 32
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
        }
Ejemplo n.º 34
0
 public IList <Calculation> FindBy(Domain.Model.Periods.PeriodId periodId, ListFetchStrategy <Calculation> fs)
 {
     return(rep.Find(c => c.PeriodId == periodId, fs));
 }
Ejemplo n.º 35
0
 public void FindBy(ListFetchStrategy <Policy> fs)
 {
     rep.GetAll(fs);
 }
Ejemplo n.º 36
0
 public void GetAllUsers(ListFetchStrategy <User> fs)
 {
     rep.GetAll <User>(fs);
 }
Ejemplo n.º 37
0
        public PageResultDto<InvoiceDto> GetByFilter(int companyId, DateTime fromDate, DateTime toDate, string invoiceNumber, int pageSize, int pageIndex, bool submitedState)
        {
            var toDateParam = toDate.Date.AddDays(1);

            var fetch = new ListFetchStrategy<Invoice>()
               .Include(o => o.InvoiceItems)
                .Include(o => o.Supplier)
                .Include(o => o.Transporter)
                //.Include(o => o.Owner)
                //                .Include(o => o.InvoiceRefrence)
                //                .Include(o => o.OrderRefrences)
                .Include(o => o.ApproveWorkFlows)
                .Include(o => o.ApproveWorkFlows.Last().CurrentWorkflowStep)
                .Include(o => o.ApproveWorkFlows.Last().CurrentWorkflowStep.ActorUser)
                //                .Include(c => c.OrderRefrences.Select(d => d.OrderItems))
                .Include(c => c.InvoiceItems.Select(d => d.Good))
                //                .Include(c => c.AdditionalPrices)
                //                .Include(c => c.AdditionalPrices.Select(d=>d.EffectiveFactor))
                .Include(c => c.InvoiceItems.Select(d => d.Good.GoodUnits))
                .WithPaging(pageSize, pageIndex + 1);

            // var invoiceType = _invoiceDtoMapper.MapInvoiceTypeDtoToInvoiceTypeEntity(invoiceTypeDto);
            invoiceRepository.Find(o =>

                (string.IsNullOrEmpty(invoiceNumber) || o.InvoiceNumber.Contains(invoiceNumber)) &&
                (!submitedState || o.State == States.Submitted) &&
               (companyId == -1 || o.OwnerId == companyId)
                && (fromDate == DateTime.MinValue || o.InvoiceDate >= fromDate.Date)
                                                  && (toDate == DateTime.MinValue || o.InvoiceDate <= toDateParam)
                                  , fetch);

            //  _invoiceRepository.Find(o => o.InvoiceType == invoiceType, fetch);

            var invoicesPageResult = fetch.PageCriteria.PageResult;

            //            var d = _invoiceRepository.GetAll();

            //            var invoiceDtos = _invoiceDtoMapper.MapToModel(d);

            var result = new PageResultDto<InvoiceDto>
                             {
                                 CurrentPage = invoicesPageResult.CurrentPage,
                                 PageSize = invoicesPageResult.PageSize,
                                 Result = invoiceDtoMapper.MapToModelWithAllIncludes(invoicesPageResult.Result).ToList(),
                                 TotalCount = invoicesPageResult.TotalCount,
                                 TotalPages = invoicesPageResult.TotalPages,
                             };
            return result;
        }
Ejemplo n.º 38
0
        //================================================================================
        public PageResult<OffhireDetail> GetPagedOffhireDetailData(long offhireId, int pageSize, int pageIndex)
        {
            var pageNumber = pageIndex + 1;

            var fetchStrategy = new ListFetchStrategy<OffhireDetail>(nolock: true)
                .WithPaging(pageSize, pageNumber);

            offhireDetailRepository.Find(sd => sd.Offhire.Id == offhireId, fetchStrategy);

            return fetchStrategy.PageCriteria.PageResult;
        }
        public void UpdateVoyageId_InvalidFuelReport()
        {
            #region Arrange

            var fetchStategy = new ListFetchStrategy<FuelReport>();

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

            long invlaidFuelReportId = this.testObjects.FuelReportRepository.GetAll(fetchStategy).First().Id + 1;

            #endregion

            #region Action

            Exception thrownException = null;

            try
            {
                FuelReport result = this.testObjects.FuelReportApplicationService.UpdateVoyageId(invlaidFuelReportId, 5);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            #endregion

            #region Assert

            Assert.IsNotNull(thrownException);

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

            #endregion
        }
Ejemplo n.º 40
0
        //================================================================================
        public List<FuelReport> GetVesselFuelReports(VesselInCompany vesselInCompany, DateTime? startDateTime, DateTime? endDateTime, bool ignoreTime = false)
        {
            var lisFetchStrategy = new ListFetchStrategy<FuelReport>(nolock: true);

            var startDateToSearch = DateTime.MinValue;
            if (startDateTime.HasValue)
            {
                if (ignoreTime)
                {
                    startDateToSearch = startDateTime.Value.Date;
                }
                else
                {
                    startDateToSearch = startDateTime.Value;
                }
            }

            var endDateToSearch = DateTime.MaxValue;
            if (endDateTime.HasValue)
            {
                if (ignoreTime)
                {
                    endDateToSearch = endDateTime.Value.Date.AddDays(1).AddMilliseconds(-1);
                }
                else
                {
                    endDateToSearch = endDateTime.Value;
                }
            }

            var result = this.fuelReportRepository.Find(
                Extensions.And(this.isFuelReportNotCancelled.Predicate, fr =>
                    fr.VesselInCompanyId == vesselInCompany.Id &&
                    fr.EventDate >= startDateToSearch &&
                    fr.EventDate <= endDateToSearch));

            return result.ToList();
        }
        public void UpdateVoyageId_ValidFuelReport_InvalidVoyageId()
        {
            #region Arrange

            var fetchStategy = new ListFetchStrategy<FuelReport>();

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

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

            long invalidVoyageId = this.testObjects.VoyageDomainService.GetAll().OrderBy(v => v.Id).LastOrDefault().Id + 1;

            #endregion

            #region Action

            Exception thrownException = null;

            try
            {
                FuelReport result = this.testObjects.FuelReportApplicationService.UpdateVoyageId(validFuelReportId, invalidVoyageId);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            #endregion

            #region Assert

            Assert.IsNotNull(thrownException);

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

            Assert.AreEqual(((BusinessRuleException)thrownException).BusinessRuleCode, "BR_FR2");

            #endregion
        }
Ejemplo n.º 42
0
        //================================================================================
        public PageResult<FuelReport> GetByFilter(long companyId, long vesselInCompanyId, int pageSize, int pageIndex)
        {
            var fetchStrategy = new ListFetchStrategy<FuelReport>(nolock: true)
                .WithPaging(pageSize, pageIndex + 1)
                .Include(c => c.FuelReportDetails)
                .OrderBy(c => c.EventDate);

            var data = this.fuelReportRepository.Find(
                                                f =>
                                                    f.VesselInCompanyId == vesselInCompanyId &&
                                                    f.VesselInCompany.CompanyId == companyId
                                    , fetchStrategy);

            return fetchStrategy.PageCriteria.PageResult;
        }
        public void UpdateVoyageId_ValidFuelReport_ValidVoyageId()
        {
            #region Arrange

            var fetchStategy = new ListFetchStrategy<FuelReport>();

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

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

            long validVoyageId = this.testObjects.VoyageDomainService.GetAll().OrderBy(v => v.Id).LastOrDefault().Id;

            #endregion

            #region Action

            Exception thrownException = null;

            FuelReport result = null;

            try
            {
                result = this.testObjects.FuelReportApplicationService.UpdateVoyageId(validFuelReportId, validVoyageId);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            #endregion

            #region Assert

            Assert.IsNull(thrownException);

            Assert.IsNotNull(result);

            this.testObjects.RegenerateUnitOfWorkScope();

            var assertionRepository = new FuelReportRepository(this.testObjects.UnitOfWorkScope, testObjects.FuelReportConfigurator);

            FuelReport updatedFuelReport = assertionRepository.Find(fr => fr.Id == validFuelReportId).FirstOrDefault();

            Assert.IsNotNull(updatedFuelReport);

            Assert.IsNotNull(updatedFuelReport.Voyage);

            Assert.AreEqual(validVoyageId, updatedFuelReport.Voyage.Id);

            #endregion
        }
Ejemplo n.º 44
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.º 45
0
 public void GetAllJob(ListFetchStrategy <Job> fs)
 {
     rep.GetAll(fs);
 }
Ejemplo n.º 46
0
 public IList <JobIndex> GetAllJobIndex(ListFetchStrategy <JobIndex> fs)
 {
     return(rep.GetAll(fs));
 }
Ejemplo n.º 47
0
 public IList <Claim> FindBy(ListFetchStrategy <Claim> fs, string employeeNo, PeriodId periodId)
 {
     return(rep.Find(c => c.PeriodId == periodId && c.EmployeeNo == employeeNo, fs));
 }
Ejemplo n.º 48
0
 public void Find(Expression <Func <Job, bool> > func, ListFetchStrategy <Job> fs)
 {
     rep.Find(func, fs);
 }
Ejemplo n.º 49
0
        //================================================================================
        public PageResult<ScrapDetail> GetPagedScrapDetailData(long scrapId, int pageSize, int pageIndex)
        {
            var pageNumber = pageIndex + 1;

            var fetchStrategy = new ListFetchStrategy<ScrapDetail>(nolock: true)
                .WithPaging(pageSize, pageNumber);

            scrapDetailRepository.Find(sd => sd.Scrap.Id == scrapId, fetchStrategy);

            return fetchStrategy.PageCriteria.PageResult;
        }
 public List<TransferType> GetAll()
 {
     var lstFetchStrategy = new ListFetchStrategy<TransferType>(Enums.FetchInUnitOfWorkOption.NoTracking);
     return Repository.GetAll(lstFetchStrategy).ToList();
 }
Ejemplo n.º 51
0
 public void FindBy(ListFetchStrategy <JobPosition> fs)
 {
     rep.GetAll(fs);
 }
Ejemplo n.º 52
0
 public IList <Claim> FindBy(ListFetchStrategy <Claim> fs, PeriodId periodId)
 {
     return(rep.Find(c => c.PeriodId == periodId, fs));
 }
Ejemplo n.º 53
0
        private List<OrderItemBalance> balanceInvoiceItemInMainUnit(InvoiceItem invoiceItem, IEnumerable<OrderItem> orderItems)
        {
            List<OrderItemBalance> generatedOrderItemBalances = new List<OrderItemBalance>();

            var fuelReportDetialListFetchStrategy = new ListFetchStrategy<FuelReportDetail>()
                            .OrderBy(frd => frd.FuelReport.EventDate);

            var orderIds = orderItems.Select(oi => oi.OrderId).ToList();

            var fuelReportDetailsOfOrderItems = fuelReportDetailRepository.Find(
                                            frd =>
                                                frd.GoodId == invoiceItem.GoodId &&
                                                frd.ReceiveReference.ReferenceType == ReferenceType.Order &&
                                                orderIds.Contains(frd.ReceiveReference.ReferenceId.Value),
                                            fuelReportDetialListFetchStrategy);

            var unassignedInvoiceItemQuantity = goodUnitConvertorDomainService.ConvertUnitValueToMainUnitValue(invoiceItem.MeasuringUnit, invoiceItem.Quantity);

            for (int index = 0; index < fuelReportDetailsOfOrderItems.Count; index++)
            {
                var checkingFuelReportDetail = fuelReportDetailsOfOrderItems[index];

                var fuelReportDetailInvoicedQuantityInMainUnit = balanceRepository.Find(b => b.FuelReportDetailId == checkingFuelReportDetail.Id).Sum(found => found.QuantityAmountInMainUnit);

                var fuelReportDetailReceivedInMainUnit = goodUnitConvertorDomainService.ConvertUnitValueToMainUnitValue(checkingFuelReportDetail.MeasuringUnit, (decimal)checkingFuelReportDetail.Receive.Value);

                var fuelReportDetailNotInvoicedQuantity = fuelReportDetailReceivedInMainUnit - fuelReportDetailInvoicedQuantityInMainUnit;

                if (fuelReportDetailNotInvoicedQuantity <= 0)
                    continue;

                var availableQuantityForBalancing = Math.Min(fuelReportDetailNotInvoicedQuantity, unassignedInvoiceItemQuantity);

                var relevantOrderItem = orderItems.Single(
                        oi =>
                            oi.OrderId == checkingFuelReportDetail.ReceiveReference.ReferenceId.Value &&
                            oi.GoodId == checkingFuelReportDetail.GoodId);

                var orderItemBalanceToAdd = new OrderItemBalance(
                    relevantOrderItem, invoiceItem, checkingFuelReportDetail,
                    availableQuantityForBalancing, checkingFuelReportDetail.Good.SharedGood.MainUnit.Abbreviation);

                balanceRepository.Add(orderItemBalanceToAdd);

                generatedOrderItemBalances.Add(orderItemBalanceToAdd);

                relevantOrderItem.UpdateInvoiced(availableQuantityForBalancing);

                unassignedInvoiceItemQuantity -= availableQuantityForBalancing;

                if (unassignedInvoiceItemQuantity <= 0)
                    break;
            }

            if (unassignedInvoiceItemQuantity != 0)
            {
                throw new BusinessRuleException("", string.Format("Invoiced Quantity for Good '{0}' has deficiencies with selected Orders.", invoiceItem.Good.Name));
            }

            return generatedOrderItemBalances;
        }
Ejemplo n.º 54
0
        //================================================================================
        public PageResult<Offhire> GetPagedData(int pageSize, int pageIndex)
        {
            var pageNumber = pageIndex + 1;

            var fetchStrategy = new ListFetchStrategy<Offhire>(nolock: true)
                .Include(s => s.VesselInCompany).Include(s => s.Introducer)
                .WithPaging(pageSize, pageNumber);

            offhireRepository.GetAll(fetchStrategy);

            return fetchStrategy.PageCriteria.PageResult;
        }
Ejemplo n.º 55
0
        //================================================================================
        public PageResult<Offhire> GetPagedDataByFilter(long? companyId, long? vesselInCompanyId, DateTime? fromDate, DateTime? toDate, int pageSize, int pageIndex)
        {
            var pageNumber = pageIndex + 1;

            var fetchStrategy = new ListFetchStrategy<Offhire>(nolock: true)
                .Include(s => s.VesselInCompany).Include(s => s.Introducer)
                .WithPaging(pageSize, pageNumber);

            offhireRepository.Find(
                e => (!companyId.HasValue || e.VesselInCompany.Company.Id == companyId) &&
                    (!vesselInCompanyId.HasValue || e.VesselInCompany.Id == vesselInCompanyId) &&
                    (!fromDate.HasValue || e.StartDateTime >= fromDate) &&
                    (!toDate.HasValue || e.StartDateTime <= toDate),
                fetchStrategy);

            return fetchStrategy.PageCriteria.PageResult;
        }
        public void UpdateFuelReportDetail_InvlaidFuelReport()
        {
            #region Arrange

            var fetchStategy = new ListFetchStrategy<FuelReport>();

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

            long invalidFuelReportId = this.testObjects.FuelReportRepository.GetAll(fetchStategy).First().Id + 1;

            #endregion

            #region Action

            Exception thrownException = null;

            FuelReportDetail result = null;

            try
            {
                //result = testObjects.Target.UpdateFuelReportDetail(invalidFuelReportId, 1, 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));

            #endregion
        }
Ejemplo n.º 57
0
 public IList <EmployeeCalculationException> FindBy(CalculationId calculationId, ListFetchStrategy <EmployeeCalculationException> fs)
 {
     return(rep.Find(c => c.CalculationId == calculationId, fs));
 }