コード例 #1
0
        public ActionResult Specials(AdminSpecialVM model)
        {
            _specialManager = SpecialManagerFactory.Create();

            if (ModelState.IsValid)
            {
                try
                {
                    var response = _specialManager.SaveSpecial(model.Special);

                    if (!response.Success)
                    {
                        return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{response.Message}"));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                var response = _specialManager.GetAllSpecials();
                model.SetSpecialItems(response.Specials);

                return(View(model));
            }

            return(RedirectToAction("Specials"));
        }
コード例 #2
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));
            }
        }
コード例 #3
0
        public ActionResult DeleteSpecial(int id)
        {
            _specialManager = SpecialManagerFactory.Create();

            var response = _specialManager.DeleteSpecial(id);

            if (!response.Success)
            {
                return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{response.Message}"));
            }

            return(RedirectToAction("Specials"));
        }
コード例 #4
0
        public ActionResult Specials()
        {
            _specialManager = SpecialManagerFactory.Create();
            var model    = new AdminSpecialVM();
            var response = _specialManager.GetAllSpecials();

            if (!response.Success)
            {
                return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{response.Message}"));
            }
            else
            {
                model.SetSpecialItems(response.Specials);
                return(View(model));
            }
        }
コード例 #5
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));
            }
        }