コード例 #1
0
        public async Task<ActionResult> GuestCmsNewsIndex(int? categoryID, int pageNumber = 1, string searchKey = "")
        {
            try
            {
                var cate = new cms_Categories();

                string rootCagetoryTitle = string.Empty;
                var cmsNews = await Task.FromResult<List<cms_News>>(uow.CmsNews.GetCmsNewsByCategoryID(categoryID ?? 0, uow.CmsCategory, out rootCagetoryTitle, searchKey.ToLower()).ToList());

                ViewBag.CmsCategories = await Task.FromResult<List<cms_Categories>>(uow.CmsCategory.GetCmsCategoriesByParentID(categoryID).ToList());
                ViewBag.CategoryParents = await Task.FromResult<List<cms_Categories>>(uow.CmsCategory.GetById(categoryID ?? 0).GetParents<cms_Categories>("cms_Categories2"));
                ViewBag.CategoryID = categoryID;
                ViewBag.CategoryTitle = rootCagetoryTitle.ToUpper();
                ViewBag.PageNumber = pageNumber;
                ViewBag.SearchKey = searchKey;

                return View(cmsNews.ToPagedList(pageNumber, 5));
            }
            catch(Exception)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
        }
コード例 #2
0
        public async Task<ActionResult> EditCmsCategory(cms_Categories cmsCategory)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (uow.CmsCategory.Update(uow.CmsCategory.GetUpdateCmsCategory(cmsCategory, 1), "ParentID", "Title", "Description", "ModifiedBy", "ModifiedDate"))
                    {
                        await uow.CommitAsync();
                        return RedirectToAction(RouteName.CmsCategoryAction.Index);
                    }
                }

                return View(cmsCategory);
            }
            catch(Exception)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
        }