public static void InstagramLikeUnLike(int LikeCount, int IsLike, string FeedId, string InstagramId, long groupId, Helper.AppSettings _appSettings, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            MongoRepository instagramFeedRepo = new MongoRepository("InstagramFeed", _appSettings);

            Domain.Socioboard.Models.Instagramaccounts _Instagramaccounts = Repositories.InstagramRepository.getInstagramAccount(InstagramId, _redisCache, dbr);
            LikesController objlikes = new LikesController();

            if (IsLike == 1)
            {
                LikeCount = LikeCount - 1;
                IsLike    = 0;
                bool ret = objlikes.DeleteLike(FeedId, _Instagramaccounts.AccessToken);
            }
            else
            {
                LikeCount = LikeCount + 1;
                IsLike    = 1;
                bool ret = objlikes.PostUserLike(FeedId, _Instagramaccounts.AccessToken);
            }

            FilterDefinition <BsonDocument> filter = new BsonDocument("FeedId", FeedId);
            var update = Builders <BsonDocument> .Update.Set("IsLike", IsLike).Set("LikeCount", LikeCount);

            instagramFeedRepo.Update <Domain.Socioboard.Models.Mongo.InstagramFeed>(update, filter);
        }
Esempio n. 2
0
        public IActionResult GetInstaAccSingle(string accId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            Domain.Socioboard.Models.Instagramaccounts pageDetails = dbr.Single <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId == accId);
            return(Ok(pageDetails));
        }
        public static string AddInstagramComment(string FeedId, string Text, string InstagramId, long groupId, Helper.AppSettings _appSettings, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            MongoRepository instagarmCommentRepo = new MongoRepository("InstagramComment", _appSettings);
            MongoRepository instagramFeedRepo    = new MongoRepository("InstagramFeed", _appSettings);

            Domain.Socioboard.Models.Mongo.InstagramComment _InstagramComment  = new Domain.Socioboard.Models.Mongo.InstagramComment();
            Domain.Socioboard.Models.Instagramaccounts      _Instagramaccounts = Repositories.InstagramRepository.getInstagramAccount(InstagramId, _redisCache, dbr);
            CommentController objComment = new CommentController();
            string            ret        = objComment.PostCommentAdd(FeedId, Text, _Instagramaccounts.AccessToken);

            if (!string.IsNullOrEmpty(ret))
            {
                try
                {
                    JObject JData      = JObject.Parse(ret);
                    string  commentid  = JData["data"]["id"].ToString();
                    string  time       = JData["data"]["created_time"].ToString();
                    string  profilepic = JData["data"]["from"]["profile_picture"].ToString();
                    string  username   = JData["data"]["from"]["username"].ToString();
                    _InstagramComment.Id             = ObjectId.GenerateNewId();
                    _InstagramComment.strId          = ObjectId.GenerateNewId().ToString();
                    _InstagramComment.FeedId         = FeedId;
                    _InstagramComment.InstagramId    = InstagramId;
                    _InstagramComment.FromProfilePic = profilepic;
                    _InstagramComment.FromName       = username;
                    _InstagramComment.CommentDate    = Convert.ToDouble(time);
                    _InstagramComment.Comment        = Text;
                    _InstagramComment.CommentId      = commentid;
                    instagarmCommentRepo.Add <Domain.Socioboard.Models.Mongo.InstagramComment>(_InstagramComment);

                    var retcomment = instagramFeedRepo.Find <Domain.Socioboard.Models.Mongo.InstagramFeed>(t => t.FeedId == FeedId);
                    var task       = Task.Run(async() => {
                        return(await retcomment);
                    });
                    List <Domain.Socioboard.Models.Mongo.InstagramFeed> lstfeed = task.Result.ToList();
                    Domain.Socioboard.Models.Mongo.InstagramFeed        feed    = lstfeed.First();
                    feed.CommentCount = feed.CommentCount + 1;
                    FilterDefinition <BsonDocument> filter = new BsonDocument("FeedId", FeedId);
                    var update = Builders <BsonDocument> .Update.Set("CommentCount", feed.CommentCount);

                    instagramFeedRepo.Update <Domain.Socioboard.Models.Mongo.InstagramFeed>(update, filter);
                    return("comment");
                }
                catch (Exception ex)
                {
                    return("");
                }
            }
            else
            {
                return("");
            }
        }
 public static string DeleteProfile(Model.DatabaseRepository dbr, string profileId, long userId, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
 {
     Domain.Socioboard.Models.Instagramaccounts fbAcc = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(profileId) && t.UserId == userId && t.IsActive).FirstOrDefault();
     if (fbAcc != null)
     {
         fbAcc.IsActive = false;
         dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(fbAcc);
         _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramAccount + profileId);
         return("Deleted");
     }
     else
     {
         return("Account Not Exist");
     }
 }
Esempio n. 5
0
        public IActionResult GetInstagramProfiles(long groupId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            List <Domain.Socioboard.Models.Groupprofiles>     lstGrpProfiles = Repositories.GroupProfilesRepository.getGroupProfiles(groupId, _redisCache, dbr);
            List <Domain.Socioboard.Models.Instagramaccounts> lstInsAcc      = new List <Domain.Socioboard.Models.Instagramaccounts>();

            foreach (var item in lstGrpProfiles.Where(t => t.profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram))
            {
                Domain.Socioboard.Models.Instagramaccounts insAcc = Repositories.InstagramRepository.getInstagramAccount(item.profileId, _redisCache, dbr);
                if (insAcc != null)
                {
                    lstInsAcc.Add(insAcc);
                }
            }
            return(Ok(lstInsAcc));
        }
        public static Domain.Socioboard.Models.Instagramaccounts getInstagramAccount(string instagramUserId, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            try
            {
                Domain.Socioboard.Models.Instagramaccounts inMemTwitterAcc = _redisCache.Get <Domain.Socioboard.Models.Instagramaccounts>(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramAccount + instagramUserId);
                if (inMemTwitterAcc != null)
                {
                    return(inMemTwitterAcc);
                }
            }
            catch { }

            List <Domain.Socioboard.Models.Instagramaccounts> lstInstagramaccounts = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(instagramUserId)).ToList();

            if (lstInstagramaccounts != null && lstInstagramaccounts.Count() > 0)
            {
                _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramAccount + instagramUserId, lstInstagramaccounts.First());
                return(lstInstagramaccounts.First());
            }
            else
            {
                return(null);
            }
        }
        public static string GetInstagramUserDetails(string profile_id, string access_token, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            string code_status = "false";

            Domain.Socioboard.Models.Mongo.InstagramUserDetails insert = new Domain.Socioboard.Models.Mongo.InstagramUserDetails();
            JObject post_data = new JObject();
            string  url       = "https://api.instagram.com/v1/users/" + profile_id + "?access_token=" + access_token;

            try
            {
                post_data = JObject.Parse(ApiInstagramHttp(url));
            }
            catch (Exception)
            {
            }

            try
            {
                dynamic item = post_data["data"];

                try
                {
                    string   insta_name   = item["username"].ToString();
                    string   full_name    = item["full_name"].ToString();
                    string   imageUrl     = item["profile_picture"].ToString();
                    string   media_count  = item["counts"]["media"].ToString();
                    DateTime Created_Time = DateTime.Now;
                    string   follower     = item["counts"]["followed_by"].ToString();
                    string   following    = item["counts"]["follows"].ToString();
                    Domain.Socioboard.Models.Instagramaccounts Instagramaccounts = Api.Socioboard.Repositories.InstagramRepository.getInstagramAccount(profile_id, _redisCache, dbr);

                    if (Instagramaccounts != null && Instagramaccounts.IsActive == true)
                    {
                        Instagramaccounts.TotalImages = Convert.ToInt32(media_count);
                        Instagramaccounts.Followers   = Convert.ToInt32(follower);
                        Instagramaccounts.FollowedBy  = Convert.ToInt32(following);
                        Instagramaccounts.InsUserName = insta_name;
                        Instagramaccounts.ProfileUrl  = imageUrl;
                        Instagramaccounts.InstagramId = profile_id;
                        dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(Instagramaccounts);
                    }

                    DateTime t1 = DateTime.Now.Date;
                    DateTime t2 = DateTime.Now.Date.AddHours(12);
                    DateTime t3 = DateTime.Now.AddDays(1).Date.AddSeconds(-1);
                    if (DateTime.Now.TimeOfDay >= t1.TimeOfDay && DateTime.Now.TimeOfDay < t2.TimeOfDay)
                    {
                        if (Instagramaccounts != null && Instagramaccounts.IsActive == true)
                        {
                            Instagramaccounts.TotalImages = Convert.ToInt32(media_count);
                            Instagramaccounts.Followers   = Convert.ToInt32(follower);
                            Instagramaccounts.FollowedBy  = Convert.ToInt32(following);
                            Instagramaccounts.InsUserName = insta_name;
                            Instagramaccounts.ProfileUrl  = imageUrl;
                            Instagramaccounts.InstagramId = profile_id;
                            dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(Instagramaccounts);
                        }
                    }
                    if (DateTime.Now.TimeOfDay >= t2.TimeOfDay && DateTime.Now.TimeOfDay < t3.TimeOfDay)
                    {
                        if (Instagramaccounts != null && Instagramaccounts.IsActive == true)
                        {
                            Instagramaccounts.TotalImages = Convert.ToInt32(media_count);
                            Instagramaccounts.Followers   = Convert.ToInt32(follower);
                            Instagramaccounts.FollowedBy  = Convert.ToInt32(following);
                            Instagramaccounts.InsUserName = insta_name;
                            Instagramaccounts.ProfileUrl  = imageUrl;
                            Instagramaccounts.InstagramId = profile_id;
                            dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(Instagramaccounts);
                        }
                    }

                    code_status = "true";
                }
                catch (Exception ex)
                {
                }
            }
            catch (Exception ex)
            {
            }
            return(code_status);
        }
        public static string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string code, long userId, long groupId, Model.DatabaseRepository dbr, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
        {
            string           ret      = string.Empty;
            oAuthInstagram   objInsta = new oAuthInstagram();
            ConfigurationIns configi  = new ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "https://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);
            UserController objusercontroller = new UserController();

            if (access != null)
            {
                Domain.Socioboard.Models.Instagramaccounts Instagramaccounts = new Domain.Socioboard.Models.Instagramaccounts();
                Domain.Socioboard.Models.Instagramaccounts objInstagramAccount;
                #region InstagramAccount
                InstagramResponse <User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token);

                objInstagramAccount             = new Domain.Socioboard.Models.Instagramaccounts();
                objInstagramAccount.AccessToken = access.access_token;
                objInstagramAccount.InstagramId = access.user.id;
                try
                {
                    objInstagramAccount.bio = access.user.bio;
                }
                catch {
                    objInstagramAccount.bio = "";
                }
                try
                {
                    objInstagramAccount.ProfileUrl = access.user.profile_picture;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.InsUserName = access.user.username;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.TotalImages = objuser.data.counts.media;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.FollowedBy = objuser.data.counts.followed_by;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.Followers = objuser.data.counts.follows;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                objInstagramAccount.UserId     = userId;
                objInstagramAccount.IsActive   = true;
                objInstagramAccount.lastUpdate = DateTime.UtcNow;
                if (objInstagramAccount.InstagramId != null)
                {
                    Instagramaccounts = Api.Socioboard.Repositories.InstagramRepository.getInstagramAccount(objInstagramAccount.InstagramId, _redisCache, dbr);
                    if (Instagramaccounts != null && Instagramaccounts.IsActive == true)
                    {
                        return("This Account is added by some body else.");
                    }
                }
                else
                {
                    return("Issue while fetching instagram userId");
                }

                if (Instagramaccounts == null)
                {
                    int isSaved = dbr.Add <Domain.Socioboard.Models.Instagramaccounts>(objInstagramAccount);
                    if (isSaved == 1)
                    {
                        List <Domain.Socioboard.Models.Instagramaccounts> lstinsAcc = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(objInstagramAccount.InstagramId)).ToList();
                        if (lstinsAcc != null && lstinsAcc.Count() > 0)
                        {
                            isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstinsAcc.First().InstagramId, lstinsAcc.First().InsUserName, userId, lstinsAcc.First().ProfileUrl, Domain.Socioboard.Enum.SocialProfileType.Instagram, dbr);
                            if (isSaved == 1)
                            {
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);

                                GetInstagramSelfFeeds(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _redisCache, dbr);
                                GetInstagramFollowing(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                GetInstagramFollower(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                new Thread(delegate()
                                {
                                    GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                    GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                }).Start();

                                return("Added_Successfully");
                            }
                        }
                    }
                }
                else
                {
                    objInstagramAccount.id = Instagramaccounts.id;
                    int isSaved = dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(objInstagramAccount);
                    if (isSaved == 1)
                    {
                        List <Domain.Socioboard.Models.Instagramaccounts> lstinsAcc = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(objInstagramAccount.InstagramId)).ToList();
                        if (lstinsAcc != null && lstinsAcc.Count() > 0)
                        {
                            isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstinsAcc.First().InstagramId, lstinsAcc.First().InsUserName, userId, lstinsAcc.First().ProfileUrl, Domain.Socioboard.Enum.SocialProfileType.Instagram, dbr);
                            if (isSaved == 1)
                            {
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);


                                //todo : codes to update feeds
                                GetInstagramSelfFeeds(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _redisCache, dbr);
                                GetInstagramFollowing(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                GetInstagramFollower(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                new Thread(delegate()
                                {
                                    GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                    GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                }).Start();



                                return("Added_Successfully");
                            }
                        }
                    }
                }
            }
            return("issue in access token fetching");

            #endregion
        }
Esempio n. 9
0
        public static int updateInstagramFeeds(Domain.Socioboard.Models.Instagramaccounts insAcc)
        {
            apiHitsCount = 0;
            DatabaseRepository dbr = new DatabaseRepository();

            Domain.Socioboard.Models.Groupprofiles _grpProfile = dbr.Single <Domain.Socioboard.Models.Groupprofiles>(t => t.profileId.Contains(insAcc.InstagramId));
            if (insAcc.lastUpdate.AddHours(1) <= DateTime.UtcNow)
            {
                if (insAcc.IsActive)
                {
                    //  Domain.Socioboard.Models.Instagramaccounts Instagramaccounts = new Domain.Socioboard.Models.Instagramaccounts();
                    Domain.Socioboard.Models.Instagramaccounts objInstagramAccount;
                    UserController   objusercontroller = new UserController();
                    ConfigurationIns configi           = new ConfigurationIns("https://api.instagram.com/oauth/authorize/", "d89b5cfa3796458ebbb2520d70eeb498", "e4663d0a287243f88ac619b5692119c8", "https://www.socioboard.com/InstagramManager/Instagram", "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
                    oAuthInstagram   _api = new oAuthInstagram();
                    _api = oAuthInstagram.GetInstance(configi);
                    InstagramResponse <User> objuser = objusercontroller.GetUserDetails(insAcc.InstagramId, insAcc.AccessToken);

                    //  objInstagramAccount = new Domain.Socioboard.Models.Instagramaccounts();


                    if (objuser != null)
                    {
                        try
                        {
                            insAcc.ProfileUrl      = objuser.data.profile_picture;
                            _grpProfile.profilePic = objuser.data.profile_picture;
                        }
                        catch (Exception ex)
                        {
                            insAcc.ProfileUrl      = insAcc.ProfileUrl;
                            _grpProfile.profilePic = insAcc.ProfileUrl;
                        }
                        try
                        {
                            insAcc.TotalImages = objuser.data.counts.media;
                        }
                        catch (Exception ex)
                        {
                            insAcc.TotalImages = insAcc.TotalImages;
                        }
                        try
                        {
                            insAcc.FollowedBy = objuser.data.counts.followed_by;
                        }
                        catch (Exception ex)
                        {
                            insAcc.FollowedBy = insAcc.FollowedBy;
                        }
                        try
                        {
                            insAcc.Followers = objuser.data.counts.follows;
                        }
                        catch (Exception ex)
                        {
                            insAcc.Followers = insAcc.Followers;
                        }
                        try
                        {
                            insAcc.bio = objuser.data.bio;
                        }
                        catch (Exception ex)
                        {
                            insAcc.bio = insAcc.bio;
                        }
                        dbr.Update <Domain.Socioboard.Models.Groupprofiles>(_grpProfile);
                        dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(insAcc);
                    }
                    while (apiHitsCount < MaxapiHitsCount)
                    {
                        try
                        {
                            GetInstagramSelfFeeds(insAcc.InstagramId, insAcc.AccessToken);
                        }
                        catch { }
                        try
                        {
                            GetInstagramUserDetails(insAcc.InstagramId, insAcc.AccessToken, insAcc);
                        }
                        catch { }
                        try
                        {
                            GetInstagramPostLikes(insAcc.InstagramId, insAcc.AccessToken);
                        }
                        catch { }
                        try
                        {
                            GetInstagramPostComments(insAcc.InstagramId, insAcc.AccessToken);
                        }
                        catch { }
                        try
                        {
                            GetInstagramFollowing(insAcc.InstagramId, insAcc.AccessToken, 1);
                        }
                        catch { }
                        try
                        {
                            GetInstagramFollower(insAcc.InstagramId, insAcc.AccessToken, 1);
                        }
                        catch { }
                    }
                    insAcc.lastUpdate = DateTime.UtcNow;
                    dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(insAcc);
                }
            }
            else
            {
                apiHitsCount = 0;
            }

            return(0);
        }
        public IActionResult AddProfileToGroup(string profileId, long groupId, long userId, Domain.Socioboard.Enum.SocialProfileType profileType)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            List <Domain.Socioboard.Models.Groupprofiles> lstGroupProfiles = GroupProfilesRepository.getGroupProfiles(groupId, _redisCache, dbr);

            if (lstGroupProfiles.Where(t => t.profileId.Equals(profileId)).Count() > 0)
            {
                return(BadRequest("profile already added"));
            }
            else
            {
                Domain.Socioboard.Models.Groups grp = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.id == groupId).FirstOrDefault();
                if (grp == null)
                {
                    return(BadRequest("Invalid groupId"));
                }
                else
                {
                    Domain.Socioboard.Models.Groupprofiles grpProfile = new Domain.Socioboard.Models.Groupprofiles();
                    if (profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook || profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage || profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage)
                    {
                        Domain.Socioboard.Models.Facebookaccounts fbAcc = Repositories.FacebookRepository.getFacebookAccount(profileId, _redisCache, dbr);
                        if (fbAcc == null)
                        {
                            return(BadRequest("Invalid profileId"));
                        }
                        if (fbAcc.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = fbAcc.FbUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = "http://graph.facebook.com/" + fbAcc.FbUserId + "/picture?type=small";
                        grpProfile.profileType    = profileType;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter)
                    {
                        Domain.Socioboard.Models.TwitterAccount twtAcc = Repositories.TwitterRepository.getTwitterAccount(profileId, _redisCache, dbr);
                        if (twtAcc == null)
                        {
                            return(BadRequest("Invalid profileId"));
                        }
                        if (twtAcc.userId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = twtAcc.twitterScreenName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = twtAcc.profileImageUrl;
                        grpProfile.profileType    = Domain.Socioboard.Enum.SocialProfileType.Twitter;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus)
                    {
                        Domain.Socioboard.Models.Googleplusaccounts gplusAccount = Repositories.GplusRepository.getGPlusAccount(profileId, _redisCache, dbr);
                        if (gplusAccount == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (gplusAccount.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = gplusAccount.GpUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = gplusAccount.GpProfileImage;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram)
                    {
                        Domain.Socioboard.Models.Instagramaccounts _Instagramaccounts = Repositories.InstagramRepository.getInstagramAccount(profileId, _redisCache, dbr);
                        if (_Instagramaccounts == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (_Instagramaccounts.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = _Instagramaccounts.InsUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = _Instagramaccounts.ProfileUrl;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn)
                    {
                        Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(profileId, _redisCache, dbr);
                        if (_LinkedInAccount == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (_LinkedInAccount.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = _LinkedInAccount.LinkedinUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = _LinkedInAccount.ProfileImageUrl;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage)
                    {
                        Domain.Socioboard.Models.LinkedinCompanyPage _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(profileId, _redisCache, dbr);
                        if (_LinkedInAccount == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (_LinkedInAccount.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = _LinkedInAccount.LinkedinPageName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = _LinkedInAccount.LogoUrl;
                    }
                    grpProfile.entryDate   = DateTime.UtcNow;
                    grpProfile.groupId     = grp.id;
                    grpProfile.profileId   = profileId;
                    grpProfile.profileType = profileType;
                    dbr.Add <Domain.Socioboard.Models.Groupprofiles>(grpProfile);
                    //codes to clear cache
                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                    //end codes to clear cache
                    return(Ok("Added Successfully"));
                }
            }
        }