Example #1
0
        public ActionResult EditIOS(Entity.AppVersion entity)
        {
            var isAdd = entity.ID == 0 ? true : false;

            LoadPlatform();
            BLL.BaseBLL <Entity.AppVersion> bll = new BLL.BaseBLL <Entity.AppVersion>();

            entity.Platforms = Entity.APPVersionPlatforms.IOS;
            entity.LogoImg   = "null";
            entity.MD5       = "null";

            ModelState.Remove("LogoImg");
            ModelState.Remove("MD5");



            //数据验证
            if (isAdd)
            {
                //判断版本是否存在
                if (bll.Exists(p => p.Platforms == Entity.APPVersionPlatforms.IOS && p.APPType == entity.APPType && p.Version == entity.Version))
                {
                    ModelState.AddModelError("Version", "该版本存在");
                }
            }
            else
            {
                if (bll.Exists(p => p.ID == entity.ID))
                {
                    return(PromptView("/admin/AppVersion", "404", "Not Found", "信息不存在或已被删除", 5));
                }
            }

            if (ModelState.IsValid)
            {
                //添加
                if (entity.ID == 0)
                {
                    var new_ver = bll.GetModel(p => p.Platforms == Entity.APPVersionPlatforms.IOS && p.APPType == entity.APPType, "VersionCode desc");
                    entity.VersionCode = new_ver == null ? 1 : new_ver.VersionCode + 1;
                    entity.AddTime     = DateTime.Now;

                    bll.Add(entity);
                }
                else //修改
                {
                    //var old_entity = db.AppVersions.Find(entity.ID);
                    //db.Entry(old_entity).CurrentValues.SetValues(entity);
                    bll.Modify(entity);
                }
                return(PromptView("/admin/AppVersion", "OK", "Success", "操作成功", 5));
            }
            else
            {
                return(View(entity));
            }
        }
        public ActionResult Edit(Entity.SysRole entity)
        {
            var isAdd = entity.ID == 0 ? true : false;

            BLL.BaseBLL <Entity.SysRole> bll = new BLL.BaseBLL <Entity.SysRole>();
            GetTree(entity.ID);

            var qx = WebHelper.GetFormString("hid_qx");

            //数据验证
            if (isAdd)
            {
                if (bll.Exists(p => p.RoleName == entity.RoleName))
                {
                    ModelState.AddModelError("RoleName", "该组名已存在");
                }
            }
            else
            {
                if (!bll.Exists(p => p.ID == entity.ID))
                {
                    return(PromptView("/admin/SysRole", "404", "Not Found", "该组不存在或已被删除", 5));
                }

                var old_entity = bll.GetModel(p => p.ID == entity.ID, null);
                //验证组名是否存在
                if (old_entity.RoleName != entity.RoleName)
                {
                    if (bll.Exists(p => p.RoleName == entity.RoleName))
                    {
                        ModelState.AddModelError("RoleName", "该组名已存在");
                    }
                }
            }

            if (ModelState.IsValid)
            {
                BLL.BLLSysRole bll_role = new BLL.BLLSysRole();
                if (entity.ID == 0)//添加
                {
                    bll_role.Add(entity, qx);
                }
                else //修改
                {
                    bll_role.Modify(entity, qx);
                }

                return(PromptView("/admin/SysRole", "OK", "Success", "操作成功", 5));
            }
            else
            {
                return(View(entity));
            }
        }
Example #3
0
        /// <summary>
        /// 验证管理员权限
        /// </summary>
        /// <param name="PageKey">页面标示符 /controller/action  小写</param>
        /// <returns></returns>
        protected bool CheckAdminPower(string PageKey, bool isPost)
        {
            if (string.IsNullOrWhiteSpace(PageKey))
            {
                isPost  = WorkContext.IsHttpPost;
                PageKey = WorkContext.PageKey;
            }
            PageKey = PageKey.ToLower();
            if (WorkContext.UserInfo.SysRole.IsAdmin)
            {
                return(true);
            }
            var result = true;

            BLL.BaseBLL <Entity.SysRoute> bll     = new BLL.BaseBLL <Entity.SysRoute>();
            List <BLL.FilterSearch>       filters = new List <BLL.FilterSearch>();

            filters.Add(new BLL.FilterSearch("IsPost", isPost.ToString(), BLL.FilterSearchContract.等于));
            filters.Add(new BLL.FilterSearch("Route", PageKey, BLL.FilterSearchContract.等于));
            if (bll.Exists(filters))
            {
                var entity = WorkContext.UserInfo.SysRole.SysRoleRoutes.Where(p => p.SysRoute.Route == PageKey && p.SysRoute.IsPost == isPost).FirstOrDefault();
                result = entity == null ? false : true;
            }
            return(result);
        }
Example #4
0
        public ActionResult EditAndroid(Entity.AppVersion entity)
        {
            var isAdd = entity.ID == 0 ? true : false;

            BLL.BaseBLL <Entity.AppVersion> bll = new BLL.BaseBLL <Entity.AppVersion>();

            entity.APPType   = Entity.APPVersionType.Standard;
            entity.Platforms = Entity.APPVersionPlatforms.Android;

            //数据验证
            if (isAdd)
            {
                //判断版本是否存在
                if (bll.Exists(p => p.Platforms == Entity.APPVersionPlatforms.Android && p.APPType == Entity.APPVersionType.Standard && p.Version == entity.Version))
                {
                    ModelState.AddModelError("Content", "该版本存在");
                }
            }
            else
            {
                if (!bll.Exists(p => p.ID == entity.ID))
                {
                    return(PromptView("/admin/AppVersion", "404", "Not Found", "信息不存在或已被删除", 5));
                }
            }

            if (ModelState.IsValid)
            {
                //添加
                if (entity.ID == 0)
                {
                    entity.AddTime = DateTime.Now;
                    bll.Add(entity);
                }
                else //修改
                {
                    bll.Modify(entity);
                }

                return(PromptView("/admin/AppVersion", "OK", "Success", "操作成功", 5));
            }
            else
            {
                return(View(entity));
            }
        }
        /// <summary>
        /// 获取树数据
        /// </summary>
        /// <param name="id">当前组ID,没有传0</param>
        private void GetTree(int id = 0)
        {
            BLL.BaseBLL <Entity.SysRole>      bll_route      = new BLL.BaseBLL <Entity.SysRole>();
            BLL.BaseBLL <Entity.SysRoleRoute> bll_role_route = new BLL.BaseBLL <Entity.SysRoleRoute>();
            Entity.SysRole role = null;
            if (id != 0)
            {
                role = bll_route.GetModel(p => p.ID == id, null);
            }

            List <Models.ViewModelTree> list = new List <Models.ViewModelTree>();
            var route_group = new BLL.BLLSysRoute().GetListGroupByTag();

            for (int i = 0; i < route_group.Count; i++)
            {
                int top_id = i + 10000;
                Models.ViewModelTree model = new Models.ViewModelTree();
                model.id   = top_id;
                model.name = route_group[i].Key;
                model.open = i < 4 ? true : false;
                model.pId  = 0;
                list.Add(model);
                foreach (var item in route_group[i].ToList())
                {
                    Models.ViewModelTree model2 = new Models.ViewModelTree();
                    model2.id   = item.ID;
                    model2.name = item.Desc;
                    model2.open = false;
                    model2.pId  = top_id;
                    if (role != null)
                    {
                        model2.is_checked = bll_role_route.Exists(p => p.SysRoleID == role.ID && p.SysRouteID == item.ID);
                    }

                    list.Add(model2);
                }
            }

            ViewData["Tree"] = JsonHelper.ToJson(list).Replace("is_checked", "checked");
        }
Example #6
0
        public ActionResult Edit(Entity.Demo entity)
        {
            var isAdd = entity.ID == 0 ? true : false;

            BLL.BaseBLL <Entity.Demo> bll = new BLL.BaseBLL <Entity.Demo>();
            string str_albums             = WebHelper.GetFormString("StrAlbums");

            if (!isAdd)
            {
                if (!bll.Exists(p => p.ID == entity.ID))
                {
                    return(PromptView("/admin/demo", "404", "Not Found", "信息不存在或已被删除", 5));
                }
            }
            if (ModelState.IsValid)
            {
                //添加
                if (entity.ID == 0)
                {
                    entity.AddTime          = DateTime.Now;
                    entity.LastUpdateTime   = DateTime.Now;
                    entity.AddUserID        = WorkContext.UserInfo.ID;
                    entity.LastUpdateUserID = WorkContext.UserInfo.ID;
                    bll.Add(entity);
                }
                else //修改
                {
                    entity.LastUpdateTime   = DateTime.Now;
                    entity.LastUpdateUserID = WorkContext.UserInfo.ID;
                    new BLL.BLLDemo().Modify(entity);
                }

                return(PromptView("/admin/demo", "OK", "Success", "操作成功", 5));
            }
            else
            {
                return(View(entity));
            }
        }
        public ActionResult Edit(Entity.CusCategory entity)
        {
            var isAdd = entity.ID == 0 ? true : false;

            LoadCategorySelect();
            BLL.BaseBLL <Entity.CusCategory> bll = new BLL.BaseBLL <Entity.CusCategory>();

            //数据验证
            if (!isAdd)
            {
                //如果要编辑的用户不存在
                if (!bll.Exists(p => p.ID == entity.ID))
                {
                    return(PromptView("/admin/CusCategory", "404", "Not Found", "信息不存在或已被删除", 5));
                }
            }

            if (ModelState.IsValid)
            {
                //添加
                if (entity.ID == 0)
                {
                    BLL.BLLCusCategory.Add(entity);
                }
                else //修改
                {
                    BLL.BLLCusCategory.Modify(entity);
                }

                return(PromptView("/admin/CusCategory", "OK", "Success", "操作成功", 5));
            }
            else
            {
                return(View(entity));
            }
        }
Example #8
0
        public ActionResult Edit(Entity.SysUser entity)
        {
            var isAdd = entity.ID == 0 ? true : false;

            BLL.BaseBLL <Entity.SysUser> bll = new BLL.BaseBLL <Entity.SysUser>();
            Load();

            if (entity.SysRoleID == 0)
            {
                ModelState.AddModelError("SysRoleID", "请选择用户组");
            }

            //数据验证
            if (isAdd)
            {
                //判断用户名是否存在
                if (!bll.Exists(p => p.UserName == entity.UserName))
                {
                    ModelState.AddModelError("UserName", "该用户名已存在");
                }
            }
            else
            {
                //如果要编辑的用户不存在
                if (!bll.Exists(p => p.ID == entity.ID))
                {
                    return(PromptView("/admin/SysUser", "404", "Not Found", "信息不存在或已被删除", 5));
                }
                ModelState.Remove("UserName");
            }

            if (ModelState.IsValid)
            {
                //添加
                if (entity.ID == 0)
                {
                    entity.RegTime       = DateTime.Now;
                    entity.Password      = SecureHelper.MD5(entity.Password);
                    entity.LastLoginTime = DateTime.Now;
                    bll.Add(entity);
                }
                else //修改
                {
                    var user = bll.GetModel(p => p.ID == entity.ID, null);
                    if (entity.Password != "litdev")
                    {
                        user.Password = SecureHelper.MD5(entity.Password);
                    }
                    user.NickName  = entity.NickName;
                    user.Gender    = entity.Gender;
                    user.Status    = entity.Status;
                    user.Avatar    = entity.Avatar;
                    user.SysRoleID = entity.SysRoleID;
                    bll.Modify(user);
                }

                return(PromptView("/admin/SysUser", "OK", "Success", "操作成功", 5));
            }
            else
            {
                return(View(entity));
            }
        }