Пример #1
0
        public JsonResult Update(SysSetVM viewModel)
        {
            var clientResult = new JsonData <object>()
            {
            };

            if (viewModel.SetID == null)
            {
                clientResult.SetClientData("n", "非法参数");
            }
            services.Command((db) =>
            {
                db.Update <SysSet>(new
                {
                    viewModel.Logo,
                    viewModel.Name,
                    viewModel.Version,
                    viewModel.Keywords,
                    viewModel.Description,
                    viewModel.Copyright,
                    viewModel.Site,
                    viewModel.ImageMaxSize,
                    viewModel.VideoMaxSize,
                    viewModel.AttachMaxSize,
                    viewModel.PageSize,
                    UpdateTime = DateTime.Now
                }, u => u.SetID == viewModel.SetID);
                CacheManager.Remove(Keys.SysSetCacheKey);
                clientResult.SetClientData("y", "操作成功");
            });
            return(Json(clientResult));
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.ActionDescriptor.IsDefined(typeof(ExemptionInjectionAttribute), false) || filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(ExemptionInjectionAttribute), false))
            {
                return;
            }
            var viewModel = new SysSetVM();

            if (!CacheManager.Contains(Keys.SysSetCacheKey))
            {
                using (var services = new DbServices())
                {
                    services.Command((db) =>
                    {
                        Mapper.Initialize(c => c.CreateMap <SysSet, SysSetVM>());
                        viewModel = Mapper.Map <SysSetVM>(db.Queryable <SysSet>().FirstOrDefault());
                    });
                }
                CacheManager.Set(Keys.SysSetCacheKey, viewModel);
            }
            else
            {
                viewModel = CacheManager.Get <SysSetVM>(Keys.SysSetCacheKey);
            }
            if (filterContext.RouteData.DataTokens[Keys.SysSetInfoInjectionKey] == null)
            {
                filterContext.RouteData.DataTokens.Add(Keys.SysSetInfoInjectionKey, viewModel);
            }
        }
Пример #3
0
        public ActionResult Detail()
        {
            var viewModel = new SysSetVM();

            services.Command((db) =>
            {
                Mapper.Initialize(c => c.CreateMap <SysSet, SysSetVM>());
                viewModel = Mapper.Map <SysSetVM>(db.Queryable <SysSet>().FirstOrDefault());
            });
            return(View(viewModel));
        }
Пример #4
0
        public ActionResult Update(Guid?id)
        {
            if (id == null)
            {
                return(Content("非法参数"));
            }
            var viewModel = new SysSetVM();

            services.Command((db) =>
            {
                Mapper.Initialize(c => c.CreateMap <SysSet, SysSetVM>());
                viewModel = Mapper.Map <SysSetVM>(db.Queryable <SysSet>().InSingle(id));
            });
            return(View(viewModel));
        }