Exemple #1
0
 public EmployerFiltersResponse GetByFilters(EmployerFiltersRequest employerFiltersRequest)
 {
     try
     {
         return(this.employerDAO.GetByFilters(employerFiltersRequest));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #2
0
 public ActionResult <EmployerFiltersResponse> GetByFilters([FromQuery] EmployerFiltersRequest employerFiltersRequest)
 {
     try
     {
         var result = this._employerManager.GetByFilters(employerFiltersRequest);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         return(Conflict(new ErrorResponse {
             Message = ex.Message.ToString()
         }));
     }
 }
Exemple #3
0
        public EmployerFiltersResponse GetByFilters(EmployerFiltersRequest employerFiltersRequest)
        {
            try
            {
                var storeProcedure = string.Format("EXEC {0} {1}, {2}, {3}, {4}, {5}, {6}, {7}",
                                                   StoreProcedureConstants.GetEmployersByFilters,
                                                   ParametersConstants.Page,
                                                   ParametersConstants.Email,
                                                   ParametersConstants.ID,
                                                   ParametersConstants.Name,
                                                   ParametersConstants.Role,
                                                   ParametersConstants.Status,
                                                   ParametersConstants.Limit);

                var listParameters = new List <SqlParameter>
                {
                    new SqlParameter(ParametersConstants.Page, SqlDbType.Int)
                    {
                        Value = employerFiltersRequest.Page
                    },
                    new SqlParameter(ParametersConstants.Email, SqlDbType.VarChar, 200)
                    {
                        Value = employerFiltersRequest.Email == null ? "" :  employerFiltersRequest.Email
                    },
                    new SqlParameter(ParametersConstants.ID, SqlDbType.Int)
                    {
                        Value = employerFiltersRequest.Id
                    },
                    new SqlParameter(ParametersConstants.Name, SqlDbType.VarChar, 180)
                    {
                        Value = employerFiltersRequest.Name == null ? "" :  employerFiltersRequest.Name
                    },
                    new SqlParameter(ParametersConstants.Role, SqlDbType.Int)
                    {
                        Value = employerFiltersRequest.Role
                    },
                    new SqlParameter(ParametersConstants.Status, SqlDbType.Int)
                    {
                        Value = employerFiltersRequest.Status
                    },
                    new SqlParameter(ParametersConstants.Limit, SqlDbType.Int)
                    {
                        Value = 5
                    }
                };

                var result = this._dataBaseContext.Set <EmployerFiltersResult>().FromSql(storeProcedure, listParameters.ToArray()).ToList();

                var employers = result.Select(x => new EmployerDTO
                {
                    Id             = x.Id,
                    Email          = x.Email,
                    Name           = x.Name,
                    LastName       = x.LastName,
                    MotherLastName = x.MotherLastName,
                    AdmissionDate  = x.AdmissionDate,
                    Status         = x.Status,
                    Role           = x.Role
                }).ToList();

                return(new EmployerFiltersResponse
                {
                    Page = employerFiltersRequest.Page,
                    Count = result.Count() > 0 ? result[0].Count : 0,
                    Employers = employers
                });
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }