public HttpResponseMessage GetActiveOpenHousesBySearchCriteria(OpenHouseDatesSearchRequest model)
        {
            HttpStatusCode statusCode = HttpStatusCode.OK;
            BaseResponse   response   = null;

            // check initial request model
            if (!ModelState.IsValid)
            {
                return(ErrorList(ModelState.Values));
            }

            try
            {
                response = new ItemsResponse <OpenHouseBase>();
                ((ItemsResponse <OpenHouseBase>)response).Items = _openHouseService.GetActiveOpenHousesBySearch(model);
                statusCode = HttpStatusCode.OK;
            }

            catch (Exception ex)
            {
                // general error
                statusCode = HttpStatusCode.ExpectationFailed;
                response   = new ErrorResponse(ex.Message);
            }

            return(Request.CreateResponse(statusCode, response));
        }
Exemplo n.º 2
0
        public List <OpenHouseBase> GetActiveOpenHousesBySearch(OpenHouseDatesSearchRequest model)
        {
            List <OpenHouseBase> openHouseList = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.OpenHouses_SelectAllActiveBySearch"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@StartDate", model.StartDate);
                if (model.EndDate.HasValue && (model.EndDate > model.StartDate))
                {
                    paramCollection.AddWithValue("@EndDate", model.EndDate);
                }
                else
                {
                    paramCollection.AddWithValue("@EndDate", null);
                }
                paramCollection.AddWithValue("@ListingKeyNumeric", model.ListingKeyNumeric);
                paramCollection.AddWithValue("@MlsListingId", model.MlsListingId);
                paramCollection.AddWithValue("@PostalCode", model.PostalCode);
                paramCollection.AddWithValue("@CityName", model.CityName);
                paramCollection.AddWithValue("@MaxRows", model.MaxRows);
            }, map : delegate(IDataReader reader, short set)
            {
                OpenHouseBase openHouse = MapOpenHouseReader(reader);

                if (openHouseList == null)
                {
                    openHouseList = new List <OpenHouseBase>();
                }

                openHouseList.Add(openHouse);
            }
                                    );

            return(openHouseList);
        }