示例#1
0
        public void AddFaction(Faction fan, User user)
        {
            using (LdxyDBEntities dbcontext = new LdxyDBEntities())
            {
                fan.CreateTime = DateTime.Now;
                dbcontext.Factions.AddObject(fan);
                dbcontext.SaveChanges();

                User us = new Models.User()
                {
                    UserName = "******",
                    Name = user.Name,
                    Password = "******",
                    RoleID = 1,
                    CreateTime = DateTime.Now,
                    Type = (int)UserType.帮派玩家,
                    FanctionID = fan.FactionID,
                    UserID = user.OUserID,
                    State = 0,
                };
                dbcontext.Users.AddObject(us);
                dbcontext.SaveChanges();

                UserRole urole = new UserRole()
                {
                    FanctionID = fan.FactionID,
                    OUserID = us.OUserID,
                    RoleID = (int)RoleEnum.帮主,
                };
                dbcontext.UserRoles.AddObject(urole);
                dbcontext.SaveChanges();
            }
        }
示例#2
0
 /// <summary>
 /// 用于向 UserRoles EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToUserRoles(UserRole userRole)
 {
     base.AddObject("UserRoles", userRole);
 }
示例#3
0
 /// <summary>
 /// 创建新的 UserRole 对象。
 /// </summary>
 /// <param name="userRoleID">UserRoleID 属性的初始值。</param>
 /// <param name="oUserID">OUserID 属性的初始值。</param>
 /// <param name="roleID">RoleID 属性的初始值。</param>
 public static UserRole CreateUserRole(global::System.Int32 userRoleID, global::System.Int32 oUserID, global::System.Int32 roleID)
 {
     UserRole userRole = new UserRole();
     userRole.UserRoleID = userRoleID;
     userRole.OUserID = oUserID;
     userRole.RoleID = roleID;
     return userRole;
 }