Beispiel #1
0
        public ActionResult Edit(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var InfoCategoryTypeList = CacheMaker.IISCache.GetOrSetThenGet("InfoCategoryType_Cache_Key", () =>
            {
                return(cateService.GetQueryable(cate => cate.CateTypeID == "InfoCategoryType").Select(cate => new SelectListItem {
                    Value = cate.ID, Text = cate.Name
                }).ToList());
            });

            ViewBag.InfoCategoryTypeList = InfoCategoryTypeList;
            InfoViewModel model = infoService.GetQueryable(i => i.ID == id).Select(i => new InfoViewModel
            {
                ID           = i.ID,
                CategoryID   = i.CategoryID,
                CategoryName = i.Category.Name,
                AddBy        = i.AddBy,
                //AddByName = i.AddByUser.Name,
                AddDate      = i.AddDate,
                Name         = i.Name,
                ImgPath      = i.ImgPath,
                Introduction = i.Introduction,
                Content      = i.Content,
                Source       = i.Source,
                Author       = i.Author,
                IsAvailable  = i.IsAvailable,
            }).FirstOrDefault();

            if (model == null)
            {
                return(View("_NoDataInLayout"));
            }
            return(View(model));
        }