示例#1
0
        public WeatherNeededResponse getWeatherData(WeatherNeededRequest request)
        {
            send(request);
            ServiceBusResponse resp = readUntilEOF();

            return((WeatherNeededResponse)resp);
        }
示例#2
0
        /// <summary>
        /// This function is called when the client navigates to *hostname*/CompanyListings/DisplayCompany/*info*
        /// </summary>
        /// <param name="id">The name of the company whos info is to be displayed</param>
        /// <returns>A view to be sent to the client</returns>
        public ActionResult DisplayCompany(string id)
        {
            if (Globals.isLoggedIn() == false)
            {
                return(RedirectToAction("Index", "Authentication"));
            }
            if ("".Equals(id))
            {
                return(View("Index"));
            }

            ServiceBusConnection connection = ConnectionManager.getConnectionObject(Globals.getUser());

            if (connection == null)
            {
                return(RedirectToAction("Index", "Authentication"));
            }

            ViewBag.CompanyName = id;
            companyNameeeee     = id;
            string location = "";

            GetCompanyInfoRequest  infoRequest  = new GetCompanyInfoRequest(new CompanyInstance(id));
            GetCompanyInfoResponse infoResponse = connection.getCompanyInfo(infoRequest);

            ViewBag.CompanyInfo = infoResponse.companyInfo;
            location            = infoResponse.companyInfo.locations[0];

            //CompanyReviewSearchRequest reviewRequest = new CompanyReviewSearchRequest(id);
            // CompanyReviewResponse reviewResponse = connection.searchCompanyReview(reviewRequest);
            // ViewBag.Reviewlist = reviewResponse.reviews;

            WeatherNeededRequest  weatherRequest  = new WeatherNeededRequest(location);
            WeatherNeededResponse weatherResponse = connection.getWeatherData(weatherRequest);

            if (!weatherResponse.result)
            {
                WeatherData wd = new WeatherData("not available", "not available", "not available", "not available", "not available", "not available");
                ViewBag.WeatherData = wd;
            }
            else
            {
                ViewBag.WeatherData = weatherResponse.weatherData;
            }



            return(View("DisplayCompany"));
        }
        private ServiceBusResponse weatherRequest(WeatherNeededRequest request)
        {
            if (authenticated == false)
            {
                return(new ServiceBusResponse(false, "Error: You must be logged in to use the weather request."));
            }

            // This class indicates to the request function where
            SendOptions sendOptions = new SendOptions();

            sendOptions.SetDestination("WeatherService");


            return(requestingEndpoint.Request <ServiceBusResponse>(request, sendOptions).
                   ConfigureAwait(false).GetAwaiter().GetResult());;
        }