예제 #1
0
 public string AddInstagramAccountFromInstaBoard(string UserId, string GroupId, string ProfileId, string AccessToken, string FriendsCount, string Name, string EmailId, string ProfilePicUrl, string TotalImage, string Followers, string Followings)
 {
     if (objUserRepository.IsUserExist(Guid.Parse(UserId)))
     {
         if (!objInstagramAccountRepository.checkInstagramUserExists(objInstagramAccount.InstagramId, Guid.Parse(UserId)))
         {
             objInstagramAccount             = new Domain.Socioboard.Domain.InstagramAccount();
             objInstagramAccount.Id          = Guid.NewGuid();
             objInstagramAccount.InstagramId = ProfileId;
             objInstagramAccount.InsUserName = Name;
             objInstagramAccount.IsActive    = true;
             objInstagramAccount.ProfileUrl  = ProfilePicUrl;
             objInstagramAccount.TotalImages = Int32.Parse(TotalImage);
             objInstagramAccount.Followers   = Int32.Parse(Followers);
             objInstagramAccount.FollowedBy  = Int32.Parse(Followings);
             objInstagramAccount.UserId      = Guid.Parse(UserId);
             objInstagramAccountRepository.addInstagramUser(objInstagramAccount);
             #region Add TeamMemberProfile
             Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
             Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
             if (objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, ProfileId))
             {
                 objTeamMemberProfile.Id               = Guid.NewGuid();
                 objTeamMemberProfile.TeamId           = objTeam.Id;
                 objTeamMemberProfile.Status           = 1;
                 objTeamMemberProfile.ProfileType      = "instagram";
                 objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                 objTeamMemberProfile.ProfileId        = ProfileId;
                 objTeamMemberProfile.ProfilePicUrl    = ProfilePicUrl;
                 objTeamMemberProfile.ProfileName      = Name;
                 objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
             }
             #endregion
             #region SocialProfile
             Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
             objSocialProfile.Id            = Guid.NewGuid();
             objSocialProfile.ProfileType   = "instagram";
             objSocialProfile.ProfileId     = ProfileId;
             objSocialProfile.UserId        = Guid.Parse(UserId);
             objSocialProfile.ProfileDate   = DateTime.Now;
             objSocialProfile.ProfileStatus = 1;
             #endregion
             #region Add SocialProfile
             if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
             {
                 objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
             }
             #endregion
             return("account added");
         }
         else
         {
             return("account already exist");
         }
     }
     else
     {
         return("user not exist");
     }
 }
예제 #2
0
        public string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            string         ret      = string.Empty;
            oAuthInstagram objInsta = new oAuthInstagram();

            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();

            _api = oAuthInstagram.GetInstance(configi);
            AccessToken access = new AccessToken();

            access = _api.AuthGetAccessToken(code);
            #region InstagramAccount
            UserController objusercontroller = new UserController();
            InstagramResponse <GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token);
            objInstagramAccount             = new Domain.Socioboard.Domain.InstagramAccount();
            objInstagramAccount.AccessToken = access.access_token;
            objInstagramAccount.InstagramId = access.user.id;
            objInstagramAccount.ProfileUrl  = access.user.profile_picture;
            objInstagramAccount.InsUserName = access.user.username;
            objInstagramAccount.TotalImages = objuser.data.counts.media;
            objInstagramAccount.FollowedBy  = objuser.data.counts.followed_by;
            objInstagramAccount.Followers   = objuser.data.counts.follows;
            objInstagramAccount.UserId      = Guid.Parse(UserId);
            #endregion


            if (!objInstagramAccountRepository.checkInstagramUserExists(objInstagramAccount.InstagramId, Guid.Parse(UserId)))
            {
                objInstagramAccountRepository.addInstagramUser(objInstagramAccount);
                #region Add TeamMemberProfile
                Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                objTeamMemberProfile.Id               = Guid.NewGuid();
                objTeamMemberProfile.TeamId           = objTeam.Id;
                objTeamMemberProfile.Status           = 1;
                objTeamMemberProfile.ProfileType      = "instagram";
                objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                objTeamMemberProfile.ProfileId        = objInstagramAccount.InstagramId;

                //Modified [13-02-15]
                objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl;
                objTeamMemberProfile.ProfileName   = objInstagramAccount.InsUserName;

                objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                #endregion
                #region SocialProfile
                Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                objSocialProfile.Id            = Guid.NewGuid();
                objSocialProfile.ProfileType   = "instagram";
                objSocialProfile.ProfileId     = objInstagramAccount.InstagramId;
                objSocialProfile.UserId        = Guid.Parse(UserId);
                objSocialProfile.ProfileDate   = DateTime.Now;
                objSocialProfile.ProfileStatus = 1;
                #endregion
                #region Add SocialProfile
                if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                }

                #endregion
                ret = "Account Added Successfully";
            }
            else
            {
                ret = "Account already Exist !";
            }

            GetIntagramImages(objInstagramAccount);
            return(ret);
        }