Exemplo n.º 1
0
        /// <summary>
        /// 角色的删除还原
        /// </summary>
        /// <param name="user">实体类(角色)</param>
        /// <param name="ID">角色ID组</param>
        /// <param name="Flag">伪删除 还原标志</param>
        /// <returns></returns>
        public ActionResult DeleteRoles(BaseRole user, string ID, string Flag)
        {
            BaseUser loginUser = Session["UserInfo"] as BaseUser;

            List<int> delIds = new List<int>();
            if (ID.Length > 1)  //选择多条
            {
                string[] idstrs = ID.Split(',');
                foreach (var item in idstrs)
                {
                    delIds.Add(int.Parse(item));
                }
            }
            else    //只选择一条
            {
                delIds.Add(int.Parse(ID));
            }

            if (Flag == "not")  //伪删除
            {
                foreach (var item in delIds)
                {
                    var removeRole = _roleService.LoadEntities(r => r.ID == item).FirstOrDefault();
                    removeRole.DeletionStateCode = 1;

                    removeRole.ModifiedUserID = loginUser.Code;
                    removeRole.ModifiedBy = loginUser.UserName;
                    removeRole.ModifiedOn = DateTime.Now;

                    _roleService.UpdateEntity(removeRole);
                }
                return Content("OK");
            }
            if (Flag == "back")   //还原
            {
                foreach (var item in delIds)
                {
                    var restoreRole = _roleService.LoadEntities(r => r.ID == item).FirstOrDefault();
                    restoreRole.DeletionStateCode = 0;

                    restoreRole.ModifiedUserID = loginUser.Code;
                    restoreRole.ModifiedBy = loginUser.UserName;
                    restoreRole.ModifiedOn = DateTime.Now;

                    _roleService.UpdateEntity(restoreRole);
                }
                return Content("OK");
            }
            else
            {
                if (_roleService.DeleteRoles(delIds) > 0)
                {
                    return Content("OK");
                }

                return Content("Error");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="role">实体类(角色)</param>
        /// <returns>添加成功标志</returns>
        public ActionResult AddRole(BaseRole role)
        {
            role.Code = Guid.NewGuid().ToString();
            role.AllowDelete = 1;
            role.AllowEdit = 1;
            role.IsVisible = 1;
            role.DeletionStateCode = 0;
            role.Enabled = 1;
            role.CreateOn = DateTime.Parse(DateTime.Now.ToString());

            BaseUser loginUser = Session["UserInfo"] as BaseUser;
            role.CreateBy = loginUser.UserName;

            //添加角色
            _roleService.AddEntity(role);

            return Content("OK");
        }
Exemplo n.º 3
0
 /// <summary>
 /// 用于向 BaseRole EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToBaseRole(BaseRole baseRole)
 {
     base.AddObject("BaseRole", baseRole);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 创建新的 BaseRole 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 public static BaseRole CreateBaseRole(global::System.Int32 id)
 {
     BaseRole baseRole = new BaseRole();
     baseRole.ID = id;
     return baseRole;
 }
Exemplo n.º 5
0
        /// <summary>
        /// 修改角色信息
        /// </summary>
        /// <param name="user">实体类(角色)</param>
        /// <returns></returns>
        public ActionResult UpdateRole(BaseRole role)
        {
            var editRole = _roleService.LoadEntities(c => c.ID == role.ID).FirstOrDefault();
            if (editRole == null)
            {
                return Content("错误信息,请您检查");
            }
            editRole.Realname = role.Realname;
            editRole.CategoryCode = role.CategoryCode;
            editRole.AllowEdit = role.AllowEdit;
            editRole.IsVisible = role.IsVisible;
            editRole.SortCode = role.SortCode;
            editRole.Enabled = role.Enabled;
            editRole.Description = role.Description;
            editRole.ModifiedOn = DateTime.Parse(DateTime.Now.ToString());

            BaseUser loginUser = Session["UserInfo"] as BaseUser;
            editRole.ModifiedUserID = loginUser.Code;
            editRole.ModifiedBy = loginUser.UserName;

            if (_roleService.UpdateEntity(editRole))
            {
                return Content("OK");
            }
            return Content("Error");
        }