Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
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.º 9
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);
        }