/// <summary>
 /// Deprecated Method for adding a new object to the Roles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRoles(Role role)
 {
     base.AddObject("Roles", role);
 }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    //WebSecurity.CreateUserAndAccount(model.AccountName, model.Password);
                    //WebSecurity.Login(model.AccountName, model.Password);
                    //var membershipUser = Membership.CreateUser(model.UserName, model.Password, model.Email);
                    //var user = userService.GetUser(model.UserName);
                    //userService.ChangeUser(model.UserName, model.QQ, true);
                    var user = new Domain.User(Guid.NewGuid(), model.UserName, model.Password, model.Email, model.QQ);
                    var role = new Domain.Role();
                    if (model.UniversityId != Guid.Empty)
                    {
                        role = userService.GetRole(Domain.RoleType.企业.ToString());
                        user.UniversityId = model.UniversityId;
                    }
                    else
                        role = userService.GetRole(Domain.RoleType.个人.ToString());

                    user.RoleId = role.Id;

                    userService.Register(user);

                    FormsAuthentication.SetAuthCookie(model.UserName, false);

                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }
            // If we got this far, something failed, redisplay form
            return Register();
        }
 /// <summary>
 /// Create a new Role object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Role CreateRole(global::System.Guid id, global::System.String name)
 {
     Role role = new Role();
     role.Id = id;
     role.Name = name;
     return role;
 }