示例#1
0
        /// <summary>
        /// Creates the facebook profile.
        /// </summary>
        /// <param name="profileModel">The profile model.</param>
        /// <returns></returns>
        public async Task <bool> CreateFacebookProfile(OAuthCreateModel profileModel)
        {
            var facebookAccount = await _facebookAccountService.GetByFacebookId(profileModel.AccountId);

            if (facebookAccount != null)
            {
                return(false);
            }
            var userProfile = new UserProfile
            {
                Email     = profileModel.Email,
                FirstName = profileModel.FirstName,
                LastName  = profileModel.LastName,
                PhotoUrl  = profileModel.PhotoUrl
            };
            var inserted = _userProfileRepository.Insert(userProfile).Entity;

            return(await _facebookAccountService.CreateFacebookAccount(inserted.UserProfileId, profileModel.AccountId));
        }
        public async Task CreateOAuthAccount([FromQuery] string auth, OAuthCreateModel model)
        {
            switch (auth)
            {
            case "google":
                await _userProfileService.CreateGoogleProfile(model);

                Response.Redirect($"oauth?auth={auth}&id={model.AccountId}");
                break;

            case "facebook":
                await _userProfileService.CreateFacebookProfile(model);

                Response.Redirect($"oauth?auth={auth}&id={model.AccountId}");
                break;

            default:
                Response.StatusCode = (int)HttpStatusCode.NoContent;
                break;
            }
        }