Exemple #1
0
        public ActionResult Edit(int id, string c, string t, string k, string d, string isShow, string isTop)
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/");
            }

            ImagesModel model = new ImagesModel();

            if (!string.IsNullOrEmpty(c) && !string.IsNullOrEmpty(t))
            {
                Album album = albumService.GetAlbumById(id);
                if (album != null)
                {
                    album.CategoryId = c;
                    album.Title = t;
                    album.Keywords = k ?? string.Empty;
                    album.Description = d ?? string.Empty;
                    album.InsertTime = DateTime.Now;
                    album.UpdatedTime = DateTime.Now;

                    if (!string.IsNullOrEmpty(isShow))
                    {
                        album.IsShow = true;
                    }
                    else
                    {
                        album.IsShow = false;
                    }

                    if (!string.IsNullOrEmpty(isTop))
                    {
                        album.IsTop = true;
                    }
                    else
                    {
                        album.IsTop = false;
                    }

                    if (albumService.UpdateAlbum(album))
                    {
                        //更新首页缓存
                        Cache.UpdateHomeData();
                    }
                }

                model.Album = album;
                model.Categories = categoryService.GetCategories("album");
            }

            return View(model);
        }
Exemple #2
0
        public ActionResult Edit(int id)
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/");
            }

            ImagesModel model = new ImagesModel();
            Album album = albumService.GetAlbumById(id);

            model.Album = album;
            model.Categories = categoryService.GetCategories("album");

            return View(model);
        }
Exemple #3
0
        public ActionResult Index(string categoryId, string keywords, string page)
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/login");
            }

            AlbumService newsService = new AlbumService();

            int tempPage = 1;

            if (!string.IsNullOrEmpty(page))
            {
                Int32.TryParse(page, out tempPage);
            }

            ImagesModel model = new ImagesModel();

            //专辑类别列表
            model.Categories = categoryService.GetCategories("album");

            //当前选中专辑类别
            model.Category = new Category();
            if (!string.IsNullOrEmpty(categoryId))
            {
                if (model.Categories != null && model.Categories.Count > 0)
                {
                    foreach (var item in model.Categories)
                    {
                        if (item.Id == categoryId)
                        {
                            model.Category = item;
                        }
                    }
                }
            }

            //专辑列表
            int tempCount = 0;
            model.AlbumList = newsService.GetAlbumList(categoryId, keywords, 15, tempPage, out tempCount);
            //分页
            if (model.AlbumList != null && model.AlbumList.Count > 0)
            {
                model.PageIndex = tempPage;
                model.PageSize = 15;
                model.PageStep = 10;
                model.AllCount = tempCount;
                if (model.AllCount % model.PageSize == 0)
                {
                    model.PageCount = model.AllCount / model.PageSize;
                }
                else
                {
                    model.PageCount = model.AllCount / model.PageSize + 1;
                }
            }

            //关键字
            model.Keywords = keywords;

            return View(model);
        }