Ejemplo n.º 1
0
        public void TestList()
        {
            UserDao userDao = new UserDao(connectionString);
            RoleDao roleDao = new RoleDao(connectionString);

            Role role   = TestHelper.CreateRole();
            int  isSave = roleDao.Save(role);

            Assert.IsTrue(isSave > 0);

            User user1 = TestHelper.CreateUser();
            User user2 = TestHelper.CreateUser();

            role.Users = new List <User>();
            role.Users.Add(user1);
            role.Users.Add(user2);
            isSave = roleDao.Update(role);
            Assert.IsTrue(isSave > 0);

            IList <User> list = userDao.List(role.Id);

            Assert.AreEqual(2, list.Count);

            int isDelete = roleDao.Delete(role.Id);

            Assert.IsTrue(isDelete > 0);

            list = userDao.List(role.Id);
            Assert.AreEqual(0, list.Count);
        }
Ejemplo n.º 2
0
        public void Delete()
        {
            const int id    = 1;
            var       model = RoleDao.Delete(id);

            Assert.IsNotNull(model);
        }
Ejemplo n.º 3
0
 public bool DeleteRole(string id)
 {
     if (string.IsNullOrEmpty(id)) throw new Exception("删除角色时没有ID");
     ISqlMapper mapper = MapperHelper.GetMapper();
     RoleDao dao = new RoleDao(mapper);
     Role_Module_ActionDao rmadao = new Role_Module_ActionDao(mapper);
     rmadao.Delete(new Role_Module_ActionQueryForm { RoleID = id });
     Role currentrole = dao.Query(new RoleQueryForm { ID = id }).FirstOrDefault();
     return dao.Delete(new RoleQueryForm { ID = id });
 }
Ejemplo n.º 4
0
 public bool Delete(string code)
 {
     try
     {
         return(_roleDao.Delete(code));
     }
     catch (Exception ex)
     {
         nlog.Error(ex, "删除角色失败!", code);
         return(false);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="roleId">角色Id</param>
        /// <returns></returns>
        public Result Delete(int roleId)
        {
            int row = roleDao.Delete(roleId);

            if (row > 0)
            {
                return(Result.除成功);
            }
            else
            {
                return(Result.除失败);
            }
        }
Ejemplo n.º 6
0
        public string Delete(string Id)
        {
            var dao    = new RoleDao();
            var result = dao.Delete(Id);

            if (result == 1)
            {
                SetAlert("Thêm bản ghi thành công!", "success");
                return("Deleted successfully");
            }
            else
            {
                SetAlert("Không thể thêm bản ghi này!", "error");
                return("Some Validation ");
            }
        }
Ejemplo n.º 7
0
        private void B_DELETE_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Really delete?", "Confirm delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                ModelRole model = new ModelRole();
                model.id        = this.id;
                model.role_code = role_code.Text;
                model.role_name = role_name.Text;

                Boolean result = roleDao.Delete(model);
                if (result)
                {
                    MessageBox.Show("ลบข้อมูลเรียบร้อยแล้ว");
                    refresh();
                }
            }
        }
Ejemplo n.º 8
0
        public void TestCURD()
        {
            Role role = TestHelper.CreateRole();

            RoleDao roleDao = new RoleDao(connectionString);
            int     isSave  = roleDao.Save(role);

            Assert.IsTrue(isSave > 0);

            role.Name = "hello";
            int isUpdate = roleDao.Update(role);

            Assert.IsTrue(isUpdate > 0);

            int isDelete = roleDao.Delete(role.Id);

            Assert.IsTrue(isDelete > 0);
        }
Ejemplo n.º 9
0
        public bool DeleteRole(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new Exception("删除角色时没有ID");
            }
            ISqlMapper            mapper = Common.GetMapperFromSession();
            RoleDao               dao    = new RoleDao(mapper);
            Role_Module_ActionDao rmadao = new Role_Module_ActionDao(mapper);

            rmadao.Delete(new Role_Module_ActionQueryForm {
                RoleID = id
            });
            Role currentrole = dao.Query(new RoleQueryForm {
                ID = id
            }).FirstOrDefault();

            return(dao.Delete(new RoleQueryForm {
                ID = id
            }));
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Delete Role
 /// </summary>
 /// <param name="objRole"></param>
 public static void DeleteRole(Role objRole)
 {
     RoleDao.Delete(objRole);
 }
Ejemplo n.º 11
0
 public bool DeleteRole(int roleId)
 {
     return(RoleDao.Delete(roleId));
 }
Ejemplo n.º 12
0
 public bool Delete(Guid RoleID)
 {
     return(ModelRole.Delete(RoleID));
 }