public HttpResponseMessage Get() { var addresses = _addressServices.GetAllAddresses(); var addressEntities = addresses as List <AddressEntity> ?? addresses.ToList(); if (addressEntities.Any()) { addressEntities = addressEntities.Where(o => o.XRefId == 36576).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, addressEntities)); } throw new ApiDataException(1000, "Address not found", HttpStatusCode.NotFound); }