Пример #1
0
        /// <summary>
        /// 创建用户并关联角色
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool InsertUsers(view_sys_user_role model)
        {
            var umodel = new sys_user();

            umodel.User_ID         = Guid.NewGuid().ToString();
            umodel.User_CreateTime = DateTime.Now;
            umodel.User_Email      = model.User_Email;
            umodel.User_IsDelete   = 1;
            umodel.User_LoginName  = model.User_LoginName;
            umodel.User_Name       = model.User_Name;
            umodel.User_Pwd        = model.User_Pwd;
            var result = _Sys_UserRepositoryS.Insert(umodel);

            if (result > 0)
            {
                var urmodel = new sys_userrole();
                urmodel.UserRole_CreateTime = DateTime.Now;
                urmodel.UserRole_ID         = Guid.NewGuid().ToString();
                urmodel.UserRole_RoleID     = model.Role_ID;
                urmodel.UserRole_UserID     = umodel.User_ID;
                result = _Sys_UserRoleRepositoryS.Insert(urmodel);
                if (result <= 0)
                {
                    _Sys_UserRepositoryS.Delete(umodel);
                }
            }
            return(result > 0);
        }
Пример #2
0
 /// <summary>
 /// 写入实体数据
 /// </summary>
 /// <param name="entity">实体类</param>
 /// <returns></returns>
 public long Insert(sys_userrole entity)
 {
     return(_Sys_UserRoleRepositoryS.Insert(entity));
 }