Пример #1
0
        public static string DeleteProfile(long groupId, long userId, string profileId, Helper.Cache _redisCache, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings)
        {
            Domain.Socioboard.Models.Groupprofiles grpProfile = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileId.Equals(profileId)).FirstOrDefault();
            Domain.Socioboard.Models.Groups        grp        = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.id == groupId).FirstOrDefault();
            string res = string.Empty;

            if (grpProfile != null)
            {
                if (grp.groupName.Equals(Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName))
                {
                    switch (grpProfile.profileType)
                    {
                    case Domain.Socioboard.Enum.SocialProfileType.Facebook:
                    {
                        res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage:
                    {
                        res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage:
                    {
                        res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.Twitter:
                    {
                        res = TwitterRepository.DeleteProfile(dbr, profileId, userId, _redisCache);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.LinkedIn:
                    {
                        res = LinkedInAccountRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage:
                    {
                        res = LinkedInAccountRepository.DeleteCompanyPageProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.Instagram:
                    {
                        res = InstagramRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics:
                    {
                        res = GplusRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.GPlus:
                    {
                        res = GplusRepository.DeleteGplusProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.YouTube:
                    {
                        res = GplusRepository.DeleteYoutubeChannelProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }

                    case Domain.Socioboard.Enum.SocialProfileType.Pinterest:
                    {
                        res = PinterestRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                        break;
                    }
                    }
                }
                else
                {
                    Groups defaultGroup = GroupsRepository.getAllGroupsofUser(userId, _redisCache, dbr).Find(t => t.groupName.Equals(Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName));
                    List <Groupprofiles> defalutGroupProfiles = getGroupProfiles(defaultGroup.id, _redisCache, dbr);
                    if (defalutGroupProfiles != null && defalutGroupProfiles.Count(t => t.profileId.Equals(profileId)) <= 0)
                    {
                        switch (grpProfile.profileType)
                        {
                        case Domain.Socioboard.Enum.SocialProfileType.Facebook:
                        {
                            res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage:
                        {
                            res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage:
                        {
                            res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.Twitter:
                        {
                            res = TwitterRepository.DeleteProfile(dbr, profileId, userId, _redisCache);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.LinkedIn:
                        {
                            res = LinkedInAccountRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage:
                        {
                            res = LinkedInAccountRepository.DeleteCompanyPageProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.Instagram:
                        {
                            res = InstagramRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics:
                        {
                            res = GplusRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.GPlus:
                        {
                            res = GplusRepository.DeleteGplusProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.YouTube:
                        {
                            res = GplusRepository.DeleteYoutubeChannelProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }

                        case Domain.Socioboard.Enum.SocialProfileType.Pinterest:
                        {
                            res = PinterestRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                            break;
                        }
                        }
                    }
                    else
                    {
                        res = "Deleted";
                    }
                }

                if (res.Equals("Deleted"))
                {
                    dbr.Delete <Domain.Socioboard.Models.Groupprofiles>(grpProfile);
                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                    return("Deleted");
                }
                else
                {
                    if (grpProfile != null)
                    {
                        dbr.Delete <Domain.Socioboard.Models.Groupprofiles>(grpProfile);
                        _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                        _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                        return("Deleted");
                    }
                    return(res);
                }
            }
            else
            {
                return("Issue while deleting Profile");
            }
        }
Пример #2
0
        public static string DeleteProfile(long userId, long groupId, Helper.Cache _redisCache, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings)
        {
            Domain.Socioboard.Models.Groups grp = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.id == groupId).FirstOrDefault();
            IList <Domain.Socioboard.Models.Groupprofiles> grpProfiles = dbr.Find <Groupprofiles>(t => t.groupId == groupId);

            if (grpProfiles.Count != 0)
            {
                foreach (Domain.Socioboard.Models.Groupprofiles grpProfile in grpProfiles)
                {
                    string res = string.Empty;
                    if (grpProfile != null)
                    {
                        try
                        {
                            switch (grpProfile.profileType)
                            {
                            case Domain.Socioboard.Enum.SocialProfileType.Facebook:
                            {
                                res = FacebookRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage:
                            {
                                res = FacebookRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage:
                            {
                                res = FacebookRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.Twitter:
                            {
                                res = TwitterRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.LinkedIn:
                            {
                                res = LinkedInAccountRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage:
                            {
                                res = LinkedInAccountRepository.DeleteCompanyPageProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.Instagram:
                            {
                                res = InstagramRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics:
                            {
                                res = GplusRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.GPlus:
                            {
                                res = GplusRepository.DeleteGplusProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.YouTube:
                            {
                                res = GplusRepository.DeleteYoutubeChannelProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }

                            case Domain.Socioboard.Enum.SocialProfileType.Pinterest:
                            {
                                res = PinterestRepository.DeleteProfile(dbr, grpProfile.profileId, userId, _redisCache, _appSettings);
                                break;
                            }
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        try
                        {
                            if (res.Equals("Deleted"))
                            {
                                dbr.Delete <Domain.Socioboard.Models.Groupprofiles>(grpProfile);
                                // dbr.Delete<Domain.Socioboard.Models.Groups>(t => t.id == groupId);
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                            }
                            else
                            {
                                if (grpProfile != null)
                                {
                                    dbr.Delete <Domain.Socioboard.Models.Groupprofiles>(grpProfile);
                                    //dbr.Delete<Domain.Socioboard.Models.Groups>(t => t.id == groupId);
                                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    else
                    {
                        return("Issue while deleting Profile");
                    }
                }
                dbr.Delete <Domain.Socioboard.Models.Groups>(grp);
                return("Deleted");
            }
            else
            {
                dbr.Delete <Domain.Socioboard.Models.Groups>(grp);
            }


            return("Deleted");
        }
Пример #3
0
        private static string DeleteGroup(long userId, string profileId, Cache _redisCache, DatabaseRepository dbr, AppSettings _appSettings, Groupprofiles grpProfile, string res)
        {
            switch (grpProfile.profileType)
            {
            case SocialProfileType.Facebook:
            {
                res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.FacebookFanPage:
            {
                res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.FacebookPublicPage:
            {
                res = FacebookRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.Twitter:
            {
                res = TwitterRepository.DeleteProfile(dbr, profileId, userId, _redisCache);
                break;
            }

            case SocialProfileType.LinkedIn:
            {
                res = LinkedInAccountRepository.DeleteProfile(dbr, profileId, userId, _redisCache,
                                                              _appSettings);
                break;
            }

            case SocialProfileType.LinkedInComapanyPage:
            {
                res = LinkedInAccountRepository.DeleteCompanyPageProfile(dbr, profileId, userId,
                                                                         _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.Instagram:
            {
                res = InstagramRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.GoogleAnalytics:
            {
                res = GplusRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.GPlus:
            {
                res = GplusRepository.DeleteGplusProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }

            case SocialProfileType.YouTube:
            {
                res = GplusRepository.DeleteYoutubeChannelProfile(dbr, profileId, userId, _redisCache,
                                                                  _appSettings);
                break;
            }

            case SocialProfileType.Pinterest:
            {
                res = PinterestRepository.DeleteProfile(dbr, profileId, userId, _redisCache, _appSettings);
                break;
            }
            }

            return(res);
        }