コード例 #1
0
        public ActionResult Edit(HomeBoxItem homeBoxItem, int homeBoxID)
        {
            try
            {
                var files = Utilities.SaveFiles(Request.Files, Utilities.GetNormalFileName(homeBoxItem.Title), StaticPaths.HomeBoxItems);

                if (files.Count > 0)
                {
                    homeBoxItem.Filename = files[0].Title;
                }

                homeBoxItem.LastUpdate = DateTime.Now;

                ViewBag.Success = true;

                if (homeBoxItem.ID == -1)
                {
                    homeBoxItem.HomeBoxID = homeBoxID;
                    HomeBoxItems.Insert(homeBoxItem);

                    UserNotifications.Send(UserID, String.Format("جدید - عکس باکس های صفحه نخست '{0}'", homeBoxItem.Title), "/Admin/HomeBoxItems/Edit/" + homeBoxItem.ID, NotificationType.Success);
                    homeBoxItem = new HomeBoxItem();
                }
                else
                {
                    HomeBoxItems.Update(homeBoxItem);
                }
            }
            catch (Exception ex)
            {
                SetErrors(ex);
            }

            return(ClearView(homeBoxItem));
        }
コード例 #2
0
        public JsonResult Get(int pageIndex, int pageSize, string pageOrder, string title, int homeBoxID)
        {
            var list = HomeBoxItems.Get(pageIndex, pageSize, pageOrder, title, homeBoxID);

            int total     = HomeBoxItems.Count(title, homeBoxID);
            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 Edit(int?id)
        {
            HomeBoxItem homeBoxItem;

            if (id.HasValue)
            {
                homeBoxItem = HomeBoxItems.GetByID(id.Value);
            }
            else
            {
                homeBoxItem = new HomeBoxItem();
            }

            return(View(homeBoxItem));
        }
コード例 #4
0
        public JsonResult Delete(int id)
        {
            var jsonSuccessResult = new JsonSuccessResult();

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

            return(new JsonResult()
            {
                Data = jsonSuccessResult
            });
        }