示例#1
0
        public ActionResult Edit(HomeBox homeBox)
        {
            try
            {
                homeBox.LastUpdate = DateTime.Now;

                ViewBag.Success = true;

                if (homeBox.ID == -1)
                {
                    HomeBoxes.Insert(homeBox);

                    UserNotifications.Send(UserID, String.Format("جدید - باکس های محصولات '{0}'", homeBox.Title), "/Admin/HomeBoxes/Edit/" + homeBox.ID, NotificationType.Success);
                    homeBox = new HomeBox();
                }
                else
                {
                    HomeBoxes.Update(homeBox);
                }
            }
            catch (Exception ex)
            {
                SetErrors(ex);
            }

            return(ClearView(homeBox));
        }
示例#2
0
        public JsonResult Get(int pageIndex, int pageSize, string pageOrder)
        {
            var list = HomeBoxes.Get(pageIndex, pageSize, pageOrder);

            int total     = HomeBoxes.Count();
            int totalPage = (int)Math.Ceiling((decimal)total / pageSize);

            if (pageSize > total)
            {
                pageSize = total;
            }

            if (list.Count < pageSize)
            {
                pageSize = list.Count;
            }

            JsonResult result = new JsonResult()
            {
                Data = new
                {
                    TotalPages = totalPage,
                    PageIndex  = pageIndex,
                    PageSize   = pageSize,
                    Rows       = list
                },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            return(result);
        }
示例#3
0
        public ActionResult Index(int homeBoxID)
        {
            ViewBag.Title = "مدیریت " + HomeBoxes.GetByID(homeBoxID).Title;

            AjaxSettings settings = new AjaxSettings
            {
                Url = "/HomeBoxProducts/Search"
            };

            return(View(model: settings));
        }
示例#4
0
        public ActionResult Edit(int?id)
        {
            HomeBox homeBox;

            if (id.HasValue)
            {
                homeBox = HomeBoxes.GetByID(id.Value);
            }
            else
            {
                homeBox = new HomeBox();
            }

            return(View(homeBox));
        }
示例#5
0
        public JsonResult Delete(int id)
        {
            var jsonSuccessResult = new JsonSuccessResult();

            try
            {
                HomeBoxes.Delete(id);
                jsonSuccessResult.Success = true;
            }
            catch (Exception ex)
            {
                jsonSuccessResult.Errors  = new string[] { ex.Message };
                jsonSuccessResult.Success = false;
            }

            return(new JsonResult()
            {
                Data = jsonSuccessResult
            });
        }
        public ActionResult Index(int pageIndex = 0, int pageSize = 25, string pageOrder = "Newest")
        {
            ViewBag.OpenMenu = true;

            var homeSlides  = SliderImages.GetSlides(SliderType.Home);
            var offerSlides = SliderImages.GetSlides(SliderType.Offer);

            var banner     = Banners.ShowPageBanners("Home");
            var producer   = Producers.Get();
            var latestNews = Articles.GetLatestPosts();

            var latestProducts = Products.GetLatestProducts();

            Products.FillProductItems(UserID, latestProducts, StaticValues.LatestProductImageSize);

            var random = Products.GetRandom(4);

            Products.FillProductItems(UserID, random, StaticValues.DefaultProductImageSize);

            var homeSlider  = Mapper.Map <List <ViewSliderImage> >(homeSlides);
            var offerSlider = Mapper.Map <List <ViewSliderImage> >(offerSlides);

            var banners        = Mapper.Map <List <ViewBanner> >(banner);
            var producerImages = Mapper.Map <List <ViewProducer> >(producer);

            #region Home Boxes

            var homeBoxes = HomeBoxes.Get();
            foreach (var item in homeBoxes)
            {
                if (item.HomeBoxType == HomeBoxType.Horizontal)
                {
                    item.Products = HomeBoxProducts.GetProductItemByBoxID(item.ID);

                    Products.FillProductItems(UserID, item.Products, StaticValues.DefaultProductImageSize);
                }
                else if (item.HomeBoxType == HomeBoxType.Group)
                {
                    item.Items = HomeBoxProducts.GetHomeBoxItemsByBoxID(item.ID);
                }
            }

            #endregion Home Boxes

            var model = new HomeSettings();

            model.CustomerComments = CustomerComments.ShowCustomerCommentsList();

            model.HomeSlider  = homeSlider;
            model.OfferSlider = offerSlider;

            model.Banners   = banners;
            model.Producers = producerImages;
            model.HomeBoxes = homeBoxes;

            model.LatestProducts = latestProducts;
            model.LatestNews     = latestNews;
            model.RandomProducts = random;

            ViewBag.Title       = String.Empty;
            ViewBag.Description = StaticValues.WebsiteDescription;
            ViewBag.Keywords    = StaticValues.WebsiteKeywords;
            ViewBag.OGType      = "article";
            ViewBag.OGImage     = StaticValues.WebsiteUrl + "/images/small-logo.jpg";

            return(View(model));
        }