public IHttpActionResult Autocomplete()
        {
            HouseholdSearchDAO     searchDAO     = new HouseholdSearchDAO(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User));
            HouseholdSearchService searchService = new HouseholdSearchService(searchDAO);
            HouseholdSearchManager searchManager = new HouseholdSearchManager(searchService);

            return(Content(HttpStatusCode.OK, searchManager.GetAutocompleteCities()));
        }
Ejemplo n.º 2
0
        //INTEGRATION TESTS
        /// <summary>
        /// Used to instantiate HouseholdSearchService, HouseholdSearchManager, and HouseholdSearchDAO similar to how the HouseholdSearchController would.
        /// </summary>

        private HouseholdSearchManager InstantiateLayers()
        {
            IHouseholdSearchDAO     searchDAO     = new HouseholdSearchDAO(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User));
            IHouseholdSearchService searchService = new HouseholdSearchService(searchDAO);
            HouseholdSearchManager  searchManager = new HouseholdSearchManager(searchService);

            return(searchManager);
        }
        public IHttpActionResult Count(string cityName, int minPrice, int maxPrice, string householdType)
        {
            HouseholdSearchDAO     searchDAO     = new HouseholdSearchDAO(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User));
            HouseholdSearchService searchService = new HouseholdSearchService(searchDAO);
            HouseholdSearchManager searchManager = new HouseholdSearchManager(searchService);

            try
            {
                var results = searchManager.GetTotalResultCountForQuery(cityName, minPrice, maxPrice, householdType);
                return(Content(HttpStatusCode.OK, results));
            }
            catch (Exception e)
            {
                // TODO: Log
                return(Content(HttpStatusCode.InternalServerError, e.Message));
            }
        }
        public IHttpActionResult Search(string cityName, int page, int minPrice, int maxPrice, string householdType)
        {
            HouseholdSearchDAO     searchDAO     = new HouseholdSearchDAO(Environment.GetEnvironmentVariable("sqlConnectionSystem", EnvironmentVariableTarget.User));
            HouseholdSearchService searchService = new HouseholdSearchService(searchDAO);
            HouseholdSearchManager searchManager = new HouseholdSearchManager(searchService);

            try
            {
                var results = searchManager.Search(cityName, page, minPrice, maxPrice, householdType);

                return(Ok(results));
                //return Content(HttpStatusCode.OK, results);
            }
            catch (Exception e)
            {
                return(InternalServerError(GenerateUserFriendlyException(e)));
                // TODO: Log
                //return Content(HttpStatusCode.InternalServerError, e.Message);
            }
        }