Esempio n. 1
0
        /// <summary>
        /// This function is called when the client navigates to *hostname*/CompanyListings/DisplayCompany/*info*
        /// </summary>
        /// <param name="info">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 info)
        {
            if (Globals.isLoggedIn() == false)
            {
                return(RedirectToAction("Index", "Authentication"));
            }
            if ("".Equals(info))
            {
                return(View("Index"));
            }

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

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

            ViewBag.CompanyName = info;

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

            ViewBag.CompanyInfo = infoResponse.companyInfo;

            GetCompanyReviewsRequest  reviewRequest  = new GetCompanyReviewsRequest(info);
            GetCompanyReviewsResponse reviewResponse = connection.getCompanyReviews(reviewRequest);

            ViewBag.CompanyReviews = reviewResponse.getReviews();

            return(View("DisplayCompany"));
        }
        /// <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;

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

            ViewBag.CompanyInfo = infoResponse.companyInfo;

            GetWeatherRequest  weatherRequest  = new GetWeatherRequest(infoResponse.companyInfo.city, infoResponse.companyInfo.province);
            GetWeatherResponse weatherResponse = connection.getWeather(weatherRequest);

            ViewBag.foundWeather = weatherResponse.result;
            if (weatherResponse.result)
            {
                ViewBag.currentTemp = weatherResponse.weather.Temperature.Metric.Value;
                ViewBag.feelTemp    = weatherResponse.weather.RealFeelTemperature.Metric.Value;
                ViewBag.weatherText = weatherResponse.weather.WeatherText;
                WeatherIcon url = new WeatherIcon();
                ViewBag.weatherIconURL = url.weatherURL[weatherResponse.weather.WeatherIcon];
            }
            else
            {
                ViewBag.currentTemp = "N/A";
                ViewBag.feelTemp    = "N/A";
                ViewBag.weatherText = "N/A";
            }

            string            company        = ViewBag.CompanyName;
            GetReviewRequest  reviewRequest  = new GetReviewRequest(company);
            GetReviewResponse reviewResponse = connection.getCompanyReviews(reviewRequest);

            ViewBag.companyReviews = reviewResponse.reviews;

            return(View("DisplayCompany"));
        }