Пример #1
0
        public ActionResult SignIn(FormCollection forms)
        {
            var userIdentity = User.Identity;

            if (userIdentity.IsAuthenticated)
            {
                var identity = userIdentity as ClaimsIdentity;

                var register = new RegisterModel()
                {
                    Email          = identity.EmailAddress(),
                    NameIdentifier = identity.NameIdentifier(),
                    UserName       = identity.Name,
                };

                var melissaCore = new MelissaCore();
                var IPAddress   = melissaCore.GetClientIpAddress(this.Request);
                var user        = Membership.GetUser(register.NameIdentifier);
                if (null == user)
                {
                    user = Membership.CreateUser(register.NameIdentifier, Guid.NewGuid().ToString(), register.Email);

                    var profile = new UserSaveProfile()
                    {
                        UserIdentifier          = user.Identifier(),
                        DisplayName             = identity.Name(),
                        FacebookTokenExpiration = identity.Expiration(),
                        IdentityProvider        = identity.IdentityProvider(),
                        FacebookAccessToken     = identity.FacebookAccessToken(),
                        Email      = register.Email,
                        FacebookId = long.Parse(register.NameIdentifier),
                        IpAddress  = IPAddress,
                    };

                    var thread = this.profileCore.Register(profile.CallObject <ProfileFull>());
                    thread.Wait();

                    return(RedirectToAction("Welcome", "Dashboard"));
                }
                else
                {
                    var profile = new UserSaveProfile()
                    {
                        UserIdentifier          = user.Identifier(),
                        FacebookTokenExpiration = identity.Expiration(),
                        FacebookAccessToken     = identity.FacebookAccessToken(),
                        IpAddress = IPAddress,
                    };

                    profile.ExecuteNonQuery();

                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("ErrorRegistration", "Error"));
            }
        }
Пример #2
0
        /// <summary>
        /// Delete Profile
        /// </summary>
        /// <param name="userId"></param>
        public void Delete(Guid userId)
        {
            if (Guid.Empty == userId)
            {
                throw new ArgumentException("userId");
            }

            var sproc = new UserSaveProfile()
            {
                Delete         = true,
                UserIdentifier = userId,
            };

            sproc.ExecuteNonQuery();
        }