コード例 #1
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 (String.IsNullOrWhiteSpace(id))
            {
                return(View("Index"));
            }

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

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

            ViewBag.CompanyName = id;


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

            ViewBag.CompanyInfo = infoResponse.companyInfo;

            if (infoResponse.result)
            {
                GetCompanyReviewsRequest  request = new GetCompanyReviewsRequest(id);
                GetCompanyReviewsResponse result  = connection.getReviews(request);
                ViewBag.Reviews = result;
            }
            else
            {
                return(View("Index"));
            }

            WeatherRequest  weatherRequest  = new WeatherRequest(infoResponse.companyInfo.locations[0]);
            WeatherResponse weatherResponse = connection.getWeather(weatherRequest);

            ViewBag.WeatherResponse = weatherResponse;

            return(View("DisplayCompany"));
        }