public static string DeleteProfile(long groupId, long userId, string profileId, Cache redisCache, DatabaseRepository dbr, AppSettings appSettings) { var grpProfile = dbr.FindFirstMatch <Groupprofiles>(t => t.groupId == groupId && t.profileId.Equals(profileId)); var res = string.Empty; if (grpProfile == null) { return("Issue while deleting Profile"); } var grp = dbr.FindFirstMatch <Groups>(t => t.id == groupId); if (grp.groupName.Equals(SocioboardConsts.DefaultGroupName)) { DeleteGroup(userId, profileId, redisCache, dbr, appSettings, grpProfile, res); } else { var defaultGroup = GroupsRepository.GetAllGroupsofUser(userId, redisCache, dbr).Find(t => t.groupName.Equals(SocioboardConsts.DefaultGroupName)); var defaultGroupProfiles = getGroupProfiles(defaultGroup.id, redisCache, dbr); if (defaultGroupProfiles != null && defaultGroupProfiles.Count(t => t.profileId.Equals(profileId)) <= 0) { DeleteGroup(userId, profileId, redisCache, dbr, appSettings, grpProfile, res); } } dbr.Delete(grpProfile); redisCache.Delete(SocioboardConsts.CacheGroupProfiles + groupId); redisCache.Delete(SocioboardConsts.CacheUserProfileCount + userId); return("Deleted"); }
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; } } } 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; } } } 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"); } }