public IHttpActionResult GetCitys([FromUri] CityParametersGetAll cityParametersGetAll)
        {
            IList <CitysDTO> citysDTO = _registrationsservice.GetCitys(cityParametersGetAll, out ReturnValues returnValues);

            if (!returnValues.Error)
            {
                return(Ok(new ResponseSuccess
                {
                    Success = true,
                    Status = Convert.ToInt32(returnValues.Code),
                    Message = returnValues.Message,
                    Data = new
                    {
                        listCitys = citysDTO
                    }
                }));
            }

            return(Ok(new ResponseError
            {
                Success = false,
                Status = Convert.ToInt32(returnValues.Code),
                Message = returnValues.Message
            }));
        }
예제 #2
0
        public IList <CitysDTO> GetCitys(CityParametersGetAll cityParametersGetAll, out ReturnValues returnValues)
        {
            IList <CitysDTO> citysDTO = null;

            returnValues = new ReturnValues();

            var StateID = String.IsNullOrEmpty(cityParametersGetAll.StateID) ? "" : cityParametersGetAll.StateID;

            try
            {
                var query = _unitOfWork.CityRepository.QueryableObject();

                if (!String.IsNullOrEmpty(StateID))
                {
                    citysDTO = query
                               .Where(row => row.StateID == StateID)
                               .Select(row => new CitysDTO()
                    {
                        ID   = row.Id,
                        Name = row.Name,
                    }).ToList();
                }

                returnValues.SetReturnValues(false, ErrorCodes.Ok, Utils.GetEnumDescription(ErrorCodes.Ok));
            }
            catch (Exception ex)
            {
                returnValues.SetReturnValues(true, ErrorCodes.InternalError, ex.Message);
            }

            return(citysDTO as IList <CitysDTO>);
        }