コード例 #1
0
        private GetEmployeesResponseModel getEmployees(GetEmployeesRequest request)
        {
            BasicHttpBinding binding = new BasicHttpBinding();
            EndpointAddress  address = new EndpointAddress(System.Configuration.ConfigurationManager.AppSettings["wcfseviceendpoint"].ToString());
            var factory = new ChannelFactory <IEmployeeService>(binding, address);
            IEmployeeService     channel = factory.CreateChannel();
            GetEmployeesResponse result  = channel.GetEmployees(request);

            return(new GetEmployeesResponseModel(result));
        }
コード例 #2
0
 public GetEmployeesResponseModel Get([FromUri] GetEmployeesRequest request)
 {
     try
     {
         return(getEmployees(request));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
        public void GetEmployeePageCount()
        {
            var controller = new EmployeeController();
            GetEmployeesRequest request = new GetEmployeesRequest
            {
                PageNumber   = 1,
                RecordInPage = 15,
                Searchtype   = SearchSortType.Default,
                SortType     = SearchSortType.Default
            };
            var result = controller.Get(request) as GetEmployeesResponseModel;

            Assert.AreEqual(15, result.RecordInPage);
        }
コード例 #4
0
        public void CheckSearchByEmpType()
        {
            var controller = new EmployeeController();
            GetEmployeesRequest request = new GetEmployeesRequest
            {
                PageNumber   = 1,
                RecordInPage = 10,
                Searchtype   = SearchSortType.EmployeeType,
                Searchvalue  = "Permanent",
                SortType     = SearchSortType.Default
            };
            var result = controller.Get(request) as GetEmployeesResponseModel;

            Assert.AreEqual("Permanent", result.Employees[0].EmpType);
        }
コード例 #5
0
            /// <summary>
            /// Handle
            /// </summary>
            /// <param name="request"></param>
            /// <param name="cancellationToken"></param>
            /// <returns></returns>
            public override async Task <List <GetMasterEmployeesResponse> > Handle(GetEmployeesRequest request, CancellationToken cancellationToken)
            {
                var empleados = await repository.GetAll()
                                .Where(e => (e.Nombre + " " + e.Apellido).Contains(request.Filtro))
                                .OrderBy(e => e.Nombre).ThenBy(e => e.Apellido)
                                .Select(e => new { e.Id, e.Nombre, e.Apellido })
                                .ToListAsync().ConfigureAwait(false);

                var result = empleados.Select(x => new GetMasterEmployeesResponse
                {
                    Id        = x.Id,
                    Nombre    = x.Nombre,
                    Apellidos = x.Apellido
                });

                return(result.ToList());
            }
コード例 #6
0
 /// <summary>
 /// Get all employees for a selected company
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <GenericResponse> GetEmployees(GetEmployeesRequest request)
 {
     return(new GenericResponse
     {
         Data = await employee.All()
                .Where(x => x.CompanyEmployees.Any(z => z.CompanyID == request.CompanyID) && x.IsLive).Select(x => new GetEmployeesReponse
         {
             CompanyID = request.CompanyID,
             CompanyName = x.Companies.FirstOrDefault(z => z.ID == request.CompanyID).CompanyName,
             ID = x.ID,
             Email = x.Email,
             Fullname = x.Fullname,
             PreferedName = x.PreferedName,
             Telephone = x.Telephone,
             DelegatedPersonID = x.DelegateAuthority.CompanyEmployeeID,
             DelegatedPerson = x.DelegateAuthority.CompanyEmployee.Fullname
         }).ToListAsync(),
         Success = true
     });
 }
コード例 #7
0
        public GetEmployeesResponse GetEmployees(GetEmployeesRequest request)
        {
            var isSearchEnable  = (int)request.Searchtype > 0 && !string.IsNullOrEmpty(request.Searchvalue);
            var filterEmployees = TempEmployeeRepo.employees
                                  .ConditionalEmployeeWhere(request.Searchtype, request.Searchvalue);
            var filterEmployeesCount = filterEmployees.Count();

            filterEmployees = filterEmployees.OrderEmployeeWhere(request.SortType, request.SortOrder)
                              .Skip(request.RecordInPage * (request.PageNumber - 1))
                              .Take(request.RecordInPage);
            GetEmployeesResponse res = new GetEmployeesResponse
            {
                Employees    = filterEmployees.ToList(),
                PageNumber   = request.PageNumber,
                RecordInPage = request.RecordInPage,
                TotalRecord  = filterEmployeesCount
            };

            return(res);
        }
コード例 #8
0
 public GetEmployeesResponse GetEmployees(GetEmployeesRequest request)
 {
     return(_repo.GetEmployees(request));
 }