예제 #1
0
        public ActionResult Index()
        {
            //get managers
            ListingManager listingManager = ListingManagerFactory.Create();
            SpecialManager specialManager = SpecialManagerFactory.Create();

            //get responses
            ListingFeaturedResponse listingFeaturedResponse = listingManager.GetFeaturedListings();
            SpecialGetAllResponse   specialResponse         = specialManager.GetAllSpecials();

            //validate responses
            if (!listingFeaturedResponse.Success || !specialResponse.Success)
            {
                return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{listingFeaturedResponse.Message} {specialResponse.Message}"));
            }
            else
            {
                //build vm
                HomeVM model = new HomeVM();

                model.SetFeaturedListingItems(listingFeaturedResponse.Listings);
                model.SetSpecialItems(specialResponse.Specials);

                return(View(model));
            }
        }
예제 #2
0
        public SpecialGetAllResponse GetAllSpecials()
        {
            var response = new SpecialGetAllResponse();

            response.Specials = Repo.GetSpecials();

            if (!response.Specials.Any())
            {
                response.Success = false;
                response.Message = "Could not load any vehicles";
            }
            else
            {
                response.Success = true;
            }

            return(response);
        }
예제 #3
0
        public ActionResult Specials()
        {
            //get manager
            SpecialManager manager = SpecialManagerFactory.Create();

            //get response
            SpecialGetAllResponse response = manager.GetAllSpecials();

            //validate
            if (!response.Success)
            {
                return(new HttpStatusCodeResult(500, $"Error in cloud. Message: {response.Message}"));
            }
            else
            {
                //create vm
                SpecialListVM model = new SpecialListVM();
                model.SetSpecialItems(response.Specials);

                return(View(model));
            }
        }