public IHttpActionResult GetDistricts([FromUri] DistrictParametersGetAll districtParametersGetAll)
        {
            IList <DistrictsDTO> districtsDTO = _registrationsservice.GetDistricts(districtParametersGetAll, out ReturnValues returnValues);

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

            return(Ok(new ResponseError
            {
                Success = false,
                Status = Convert.ToInt32(returnValues.Code),
                Message = returnValues.Message
            }));
        }
Beispiel #2
0
        public IList <DistrictsDTO> GetDistricts(DistrictParametersGetAll districtParametersGetAll, out ReturnValues returnValues)
        {
            IList <DistrictsDTO> districtsDTO = null;

            returnValues = new ReturnValues();

            var CityID = String.IsNullOrEmpty(districtParametersGetAll.CityID) ? "" : districtParametersGetAll.CityID;

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

                if (!String.IsNullOrEmpty(CityID))
                {
                    districtsDTO = query
                                   .Where(row => row.CityID == CityID)
                                   .Select(row => new DistrictsDTO()
                    {
                        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(districtsDTO as IList <DistrictsDTO>);
        }