public GroupMembers Load() { using (GroupMembersRepository repo = new GroupMembersRepository(base.DataContext)) { return((GroupMembers)repo.Load <GroupMember>(this, repo.GetItems())); } }
private static Domain.Socioboard.Domain.Groups AddGroupByUserId(Guid userId) { Domain.Socioboard.Domain.Groups groups = new Domain.Socioboard.Domain.Groups(); GroupsRepository objGroupRepository = new GroupsRepository(); UserRepository userRepo = new UserRepository(); GroupMembersRepository grpMemberRepo = new GroupMembersRepository(); groups.Id = Guid.NewGuid(); groups.GroupName = ConfigurationManager.AppSettings["DefaultGroupName"]; groups.UserId = userId; groups.EntryDate = DateTime.UtcNow; objGroupRepository.AddGroup(groups); Domain.Socioboard.Domain.User objUser = userRepo.getUsersById(groups.UserId); Domain.Socioboard.Domain.Groupmembers grpMember = new Domain.Socioboard.Domain.Groupmembers(); grpMember.Id = Guid.NewGuid(); grpMember.Groupid = groups.Id.ToString(); grpMember.Userid = groups.UserId.ToString(); grpMember.Status = Domain.Socioboard.Domain.GroupUserStatus.Accepted; grpMember.Emailid = objUser.EmailId; grpMember.IsAdmin = true; grpMemberRepo.AddGroupMemeber(grpMember); return(groups); }
public GroupMembers Load(Dictionary <string, string> @params) { using (GroupMembersRepository repo = new GroupMembersRepository(base.DataContext)) { return((GroupMembers)repo.Load <GroupMember>(this, repo.GetItems(@params))); } }
public IActionResult CreateGroup(Domain.Socioboard.Models.Groups group) { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); //if (dbr.Find<Domain.Socioboard.Models.Groups>(t => t.adminId == group.adminId && t.groupName.Equals(group.groupName)).Count > 0) if (dbr.Find <Domain.Socioboard.Models.Groups>(t => t.groupName.Equals(group.groupName)).Count > 0) { return(Ok("Team Name Already Exist")); } group.createdDate = System.DateTime.UtcNow; int res = dbr.Add <Domain.Socioboard.Models.Groups>(group); if (res == 1) { Domain.Socioboard.Models.User user = dbr.FindSingle <User>(t => t.Id == group.adminId); long GroupId = dbr.FindSingle <Domain.Socioboard.Models.Groups>(t => t.adminId == group.adminId && t.groupName.Equals(group.groupName)).id; GroupMembersRepository.createGroupMember(GroupId, user, _redisCache, dbr); _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserGroups + group.adminId); return(Ok("Team Added Successfully ")); } else { return(Ok("Error while adding Group")); } }
public GroupMember Save() { using (GroupMembersRepository repo = new GroupMembersRepository(DataContext)){ if (_id == 0) { _id = repo.Insert(GroupId, UserId); } else { repo.Update(Id, GroupId, UserId); } return(this); } }
public bool GrpMem(Domain.Socioboard.Domain.User user) { GroupsRepository grpRep = new GroupsRepository(); GroupMembersRepository grpMemRep = new GroupMembersRepository(); UserRepository userRepo = new UserRepository(); // Domain.Socioboard.Domain.User user = userRepo.getUserInfoByEmail(Email); //foreach (var user in lstUser) //{ try { List <Domain.Socioboard.Domain.Groups> lstGroups = grpRep.getAlluserGroups(user.Id); foreach (var item in lstGroups) { try { if (user != null) { Domain.Socioboard.Domain.Groupmembers grpMember = new Domain.Socioboard.Domain.Groupmembers(); grpMember.Id = Guid.NewGuid(); grpMember.Emailid = user.EmailId; grpMember.Groupid = item.Id.ToString(); grpMember.IsAdmin = true; grpMember.Status = Domain.Socioboard.Domain.GroupUserStatus.Accepted; grpMember.Userid = item.UserId.ToString(); if (!grpMemRep.checkMemberExistsingroup(grpMember.Groupid, grpMember.Userid)) { grpMemRep.AddGroupMemeber(grpMember); } } } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } } } catch (Exception e) { } //} return(true); }
public IActionResult FacebookLogin(string AccessToken, Domain.Socioboard.Enum.SBAccountType accType) { dynamic profile = FbUser.getFbUser(AccessToken); if (Convert.ToString(profile) == "Invalid Access Token") { return(Ok("Invalid Access Token")); } try { string EmailId = string.Empty; try { EmailId = (Convert.ToString(profile["email"])); } catch { } if (string.IsNullOrEmpty(EmailId)) { return(Ok("Facebook Not retuning Email")); } try { User inMemUser = _redisCache.Get <User>(EmailId); if (inMemUser != null) { return(Ok(inMemUser)); } } catch (Exception ex) { _logger.LogInformation(ex.Message); _logger.LogError(ex.StackTrace); } DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); IList <User> lstUser = dbr.Find <User>(t => t.EmailId.Equals(EmailId)); if (lstUser != null && lstUser.Count() > 0) { DateTime d1 = DateTime.UtcNow; //User userTable = dbr.Single<User>(t => t.EmailId == EmailId); //userTable.LastLoginTime = d1; lstUser.First().LastLoginTime = d1; dbr.Update <User>(lstUser.First()); _redisCache.Set <User>(lstUser.First().EmailId, lstUser.First()); return(Ok(lstUser.First())); } else { Domain.Socioboard.Models.Facebookaccounts fbacc = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(Convert.ToString(profile["id"]), _redisCache, dbr); if (fbacc != null && fbacc.IsActive == true) { return(Ok("Facebook account added by other user.")); } Domain.Socioboard.Models.User user = new Domain.Socioboard.Models.User(); if (accType == Domain.Socioboard.Enum.SBAccountType.Free) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Free; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Deluxe) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Deluxe; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Premium) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Premium; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Topaz) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Topaz; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Platinum) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Platinum; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Gold) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Gold; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Ruby) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Ruby; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Standard) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Standard; } user.ActivationStatus = Domain.Socioboard.Enum.SBUserActivationStatus.Active; user.CreateDate = DateTime.UtcNow; user.EmailId = EmailId; user.ExpiryDate = DateTime.UtcNow.AddDays(1); user.PaymentType = Domain.Socioboard.Enum.PaymentType.paypal; user.UserName = "******"; user.EmailValidateToken = "Facebook"; try { user.ProfilePicUrl = "https://graph.facebook.com/" + Convert.ToString(profile["id"]) + "/picture?type=small"; } catch { } user.PaymentStatus = Domain.Socioboard.Enum.SBPaymentStatus.UnPaid; try { user.FirstName = (Convert.ToString(profile["name"])); } catch { } user.RegistrationType = Domain.Socioboard.Enum.SBRegistrationType.Faceboook; int SavedStatus = dbr.Add <Domain.Socioboard.Models.User>(user); User nuser = dbr.Single <User>(t => t.EmailId.Equals(user.EmailId)); if (SavedStatus == 1 && nuser != null) { Groups group = new Groups(); group.adminId = nuser.Id; group.createdDate = DateTime.UtcNow; group.groupName = Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName; SavedStatus = dbr.Add <Groups>(group); if (SavedStatus == 1) { Groups ngrp = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.adminId == nuser.Id && t.groupName.Equals(Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName)).FirstOrDefault(); GroupMembersRepository.createGroupMember(ngrp.id, nuser, _redisCache, dbr); // Adding Facebook Profile Api.Socioboard.Repositories.FacebookRepository.AddFacebookAccount(profile, FbUser.getFbFriends(AccessToken), dbr, nuser.Id, ngrp.id, Domain.Socioboard.Enum.FbProfileType.FacebookProfile, AccessToken, _redisCache, _appSettings, _logger); } } return(Ok(nuser)); } } catch { return(Ok("Invalid Access Token")); } }
public void Delete() { using (GroupMembersRepository repo = new GroupMembersRepository(DataContext)){ repo.Delete(_id); } }
public GroupMember Load(int id) { using (GroupMembersRepository repo = new GroupMembersRepository(DataContext)){ return(repo.LoadOne <GroupMember>(this, repo.GetItem(id))); } }
public IActionResult LeaveGroup(long groupId, long userId) { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); return(Ok(GroupMembersRepository.LeaveTeam(groupId, userId, _redisCache, dbr))); }
public IActionResult DeleteGroup(long groupId) { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); return(Ok(GroupMembersRepository.adminDelete(groupId, _redisCache, dbr))); }
public IActionResult GetGroupAdmin(long groupId) { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); return(Ok(GroupMembersRepository.getGroupadmin(groupId, _redisCache, dbr))); }
public IActionResult GoogleLogin(string code, SBAccountType accType) { var refreshToken = string.Empty; string accessToken; var objoAuthTokenGPlus = new oAuthTokenGPlus(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri); var objToken = new oAuthToken(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri); JObject userInfo; try { var objRefresh = objoAuthTokenGPlus.GetRefreshToken(code); var objAccessToken = JObject.Parse(objRefresh); _logger.LogInformation(objAccessToken.ToString()); try { refreshToken = objAccessToken["refresh_token"].ToString(); } catch (Exception ex) { _logger.LogError(ex.StackTrace); } accessToken = objAccessToken["access_token"].ToString(); var user = objToken.GetUserInfo("self", accessToken); _logger.LogInformation(user); userInfo = JObject.Parse(JArray.Parse(user)[0].ToString()); } catch (Exception ex) { _logger.LogError(ex.StackTrace); return(Ok("Access Token Not Found")); } var emailId = string.Empty; try { emailId = Convert.ToString(userInfo["email"]); } catch (Exception ex) { _logger.LogError(ex.StackTrace); } if (string.IsNullOrEmpty(emailId)) { return(Ok("Google not returning Email")); } try { var inMemUser = _redisCache.Get <User>(emailId); if (inMemUser != null) { return(Ok(inMemUser)); } } catch (Exception ex) { _logger.LogError(ex.StackTrace); } var dbr = new DatabaseRepository(_logger, _appEnv); var signedInUser = dbr.FindFirstMatch <User>(t => t.EmailId.Equals(emailId)); if (signedInUser != null) { if (!signedInUser.SocialLoginEnableGo) { return(Ok("Account isn't sign-up with google!")); } CustomTaskFactory.Instance.Start(() => { if (signedInUser.RefrralCode == null) { signedInUser.RefrralCode = $"{SocioboardApiConstants.ApplicationName}" + signedInUser.Id; } signedInUser.LastLoginTime = DateTime.UtcNow; dbr.Update(signedInUser); _redisCache.Set(signedInUser.EmailId, signedInUser); }); return(Ok(signedInUser)); } var googleUser = new User { AccountType = accType, PaymentType = PaymentType.paypal, ActivationStatus = SBUserActivationStatus.Active, CreateDate = DateTime.UtcNow, EmailId = emailId, ExpiryDate = DateTime.UtcNow.AddDays(1), UserName = $"{SocioboardApiConstants.ApplicationName}", EmailValidateToken = "Google", UserType = "User", LastLoginTime = DateTime.UtcNow, SocialLoginEnableGo = true, SocialLoginEnableFb = false, PaymentStatus = SBPaymentStatus.UnPaid, RegistrationType = SBRegistrationType.Google, TrailStatus = UserTrailStatus.active }; if (googleUser.AccountType == SBAccountType.Free) { googleUser.ExpiryDate = DateTime.UtcNow.AddDays(15); } try { googleUser.FirstName = Convert.ToString(userInfo["name"]); } catch (Exception ex) { _logger.LogError(ex.StackTrace); } var savedStatus = dbr.Add(googleUser); var googleUserAccount = dbr.FindFirstMatch <User>(t => t.EmailId.Equals(googleUser.EmailId)); CustomTaskFactory.Instance.Start(() => { if (savedStatus != 1 || googleUserAccount == null) { return; } _redisCache.Set(emailId, googleUserAccount); var group = new Groups(); group.adminId = googleUserAccount.Id; group.createdDate = DateTime.UtcNow; group.groupName = SocioboardConsts.DefaultGroupName; savedStatus = dbr.Add(group); if (savedStatus != 1) { return; } var groupDetails = dbr.Find <Groups>(t => t.adminId == googleUserAccount.Id && t.groupName.Equals(SocioboardConsts.DefaultGroupName)) .FirstOrDefault(); if (groupDetails == null) { return; } GroupMembersRepository.CreateGroupMember(groupDetails.id, googleUserAccount, _redisCache, dbr); GplusRepository.AddGplusAccount(userInfo, dbr, googleUserAccount.Id, groupDetails.id, accessToken, refreshToken, _redisCache, _appSettings, _logger); }); return(Ok(googleUserAccount)); }
public IActionResult GoogleLoginPhone(string refreshToken, string accessToken, SBAccountType accType) { var ret = string.Empty; var objRefresh = string.Empty; var ObjoAuthTokenGPlus = new oAuthTokenGPlus(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri); var objToken = new oAuthToken(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri); var userinfo = new JObject(); try { var user = objToken.GetUserInfo("self", accessToken); _logger.LogInformation(user); userinfo = JObject.Parse(JArray.Parse(user)[0].ToString()); } catch (Exception ex) { _logger.LogInformation(ex.Message); _logger.LogError(ex.StackTrace); ret = "Access Token Not Found"; return(Ok(ret)); } var EmailId = string.Empty; try { EmailId = Convert.ToString(userinfo["email"]); } catch { } if (string.IsNullOrEmpty(EmailId)) { return(Ok("Google Not retuning Email")); } try { var inMemUser = _redisCache.Get <User>(EmailId); if (inMemUser != null) { return(Ok(inMemUser)); } } catch (Exception ex) { _logger.LogInformation(ex.Message); _logger.LogError(ex.StackTrace); } var dbr = new DatabaseRepository(_logger, _appEnv); var lstUser = dbr.Find <User>(t => t.EmailId.Equals(EmailId)); if (lstUser != null && lstUser.Count() > 0) { var d1 = DateTime.UtcNow; //User userTable = dbr.Single<User>(t => t.EmailId == EmailId); //userTable.LastLoginTime = d1; lstUser.First().LastLoginTime = d1; dbr.Update(lstUser.First()); _redisCache.Set(lstUser.First().EmailId, lstUser.First()); return(Ok(lstUser.First())); } { var gplusAcc = GplusRepository.getGPlusAccount(Convert.ToString(userinfo["id"]), _redisCache, dbr); if (gplusAcc != null && gplusAcc.IsActive) { return(BadRequest("GPlus account added by other user.")); } var user = new User(); if (accType == SBAccountType.Free) { user.AccountType = SBAccountType.Free; } else if (accType == SBAccountType.Deluxe) { user.AccountType = SBAccountType.Deluxe; } else if (accType == SBAccountType.Premium) { user.AccountType = SBAccountType.Premium; } else if (accType == SBAccountType.Topaz) { user.AccountType = SBAccountType.Topaz; } else if (accType == SBAccountType.Platinum) { user.AccountType = SBAccountType.Platinum; } else if (accType == SBAccountType.Gold) { user.AccountType = SBAccountType.Gold; } else if (accType == SBAccountType.Ruby) { user.AccountType = SBAccountType.Ruby; } else if (accType == SBAccountType.Standard) { user.AccountType = SBAccountType.Standard; } user.PaymentType = PaymentType.paypal; user.ActivationStatus = SBUserActivationStatus.Active; user.CreateDate = DateTime.UtcNow; user.EmailId = EmailId; user.ExpiryDate = DateTime.UtcNow.AddDays(30); user.UserName = "******"; user.EmailValidateToken = "Google"; user.UserType = "User"; user.LastLoginTime = DateTime.UtcNow; user.PaymentStatus = SBPaymentStatus.UnPaid; user.SocialLoginEnableGo = true; try { user.FirstName = Convert.ToString(userinfo["name"]); } catch { } user.RegistrationType = SBRegistrationType.Google; var SavedStatus = dbr.Add(user); var nuser = dbr.Single <User>(t => t.EmailId.Equals(user.EmailId)); if (SavedStatus == 1 && nuser != null) { var group = new Groups(); group.adminId = nuser.Id; group.createdDate = DateTime.UtcNow; group.groupName = SocioboardConsts.DefaultGroupName; SavedStatus = dbr.Add(group); if (SavedStatus == 1) { var ngrp = dbr.Find <Groups>(t => t.adminId == nuser.Id && t.groupName.Equals(SocioboardConsts.DefaultGroupName)) .FirstOrDefault(); GroupMembersRepository.CreateGroupMember(ngrp.id, nuser, _redisCache, dbr); // Adding GPlus Profile GplusRepository.AddGplusAccount(userinfo, dbr, nuser.Id, ngrp.id, accessToken, refreshToken, _redisCache, _appSettings, _logger); } } return(Ok(nuser)); } }
public IActionResult Register(User user) { user.CreateDate = DateTime.UtcNow; user.ExpiryDate = DateTime.UtcNow.AddDays(1); user.EmailValidateToken = SBHelper.RandomString(20); user.ValidateTokenExpireDate = DateTime.UtcNow.AddDays(1); user.ActivationStatus = Domain.Socioboard.Enum.SBUserActivationStatus.MailSent; user.Password = SBHelper.MD5Hash(user.Password); user.UserName = "******"; user.PayPalAccountStatus = Domain.Socioboard.Enum.PayPalAccountStatus.notadded; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); IList <User> lstUser = dbr.Find <User>(t => t.EmailId.Equals(user.EmailId)); if (lstUser != null && lstUser.Count() > 0) { return(BadRequest("EmailID Exist")); } IList <User> lstUser1 = dbr.Find <User>(a => a.PhoneNumber.Equals(user.PhoneNumber)); if (lstUser1 != null && lstUser1.Count() > 0) { return(BadRequest("Phone Number Exist")); } int SavedStatus = dbr.Add <Domain.Socioboard.Models.User>(user); User nuser = dbr.Single <User>(t => t.EmailId.Equals(user.EmailId)); if (SavedStatus == 1 && nuser != null) { Groups group = new Groups(); group.adminId = nuser.Id; // group.id = nuser.Id; group.createdDate = DateTime.UtcNow; group.groupName = Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName; SavedStatus = dbr.Add <Groups>(group); if (SavedStatus == 1) { long GroupId = dbr.FindSingle <Domain.Socioboard.Models.Groups>(t => t.adminId == group.adminId && t.groupName.Equals(group.groupName)).id; GroupMembersRepository.createGroupMember(GroupId, nuser, _redisCache, dbr); } try { string path = _appEnv.WebRootPath + "\\views\\mailtemplates\\registrationmail.html"; string html = System.IO.File.ReadAllText(path); html = html.Replace("[FirstName]", nuser.FirstName); html = html.Replace("[AccountType]", nuser.AccountType.ToString()); html = html.Replace("[ActivationLink]", _appSettings.Domain + "/Home/Active?Token=" + nuser.EmailValidateToken + "&id=" + nuser.Id); _emailSender.SendMailSendGrid(_appSettings.frommail, "", nuser.EmailId, "", "", "Socioboard Email conformation Link", html, _appSettings.SendgridUserName, _appSettings.SendGridPassword); } catch { return(Ok()); } } else { return(BadRequest("Can't create user")); } return(Ok("Email verification mail sent successfully.")); }
public IActionResult RetainGrpMber(long userId) { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); return(Ok(GroupMembersRepository.RetainGrpMber(userId, _redisCache, dbr))); }
public GroupMembersService(GroupMembersRepository repo) { _repo = repo; }
public IActionResult GoogleLogin(string code, Domain.Socioboard.Enum.SBAccountType accType) { string ret = string.Empty; string objRefresh = string.Empty; string refreshToken = string.Empty; string access_token = string.Empty; oAuthTokenGPlus ObjoAuthTokenGPlus = new oAuthTokenGPlus(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri); oAuthToken objToken = new oAuthToken(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri); JObject userinfo = new JObject(); try { objRefresh = ObjoAuthTokenGPlus.GetRefreshToken(code); JObject objaccesstoken = JObject.Parse(objRefresh); _logger.LogInformation(objaccesstoken.ToString()); try { refreshToken = objaccesstoken["refresh_token"].ToString(); } catch { } access_token = objaccesstoken["access_token"].ToString(); string user = objToken.GetUserInfo("self", access_token.ToString()); _logger.LogInformation(user); userinfo = JObject.Parse(JArray.Parse(user)[0].ToString()); } catch (Exception ex) { //access_token = objaccesstoken["access_token"].ToString(); //ObjoAuthTokenGPlus.RevokeToken(access_token); _logger.LogInformation(ex.Message); _logger.LogError(ex.StackTrace); ret = "Access Token Not Found"; return(Ok(ret)); } string EmailId = string.Empty; try { EmailId = (Convert.ToString(userinfo["email"])); } catch { } if (string.IsNullOrEmpty(EmailId)) { return(Ok("Google Not retuning Email")); } try { User inMemUser = _redisCache.Get <User>(EmailId); if (inMemUser != null) { return(Ok(inMemUser)); } } catch (Exception ex) { _logger.LogInformation(ex.Message); _logger.LogError(ex.StackTrace); } DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); IList <User> lstUser = dbr.Find <User>(t => t.EmailId.Equals(EmailId)); if (lstUser != null && lstUser.Count() > 0) { DateTime d1 = DateTime.UtcNow; //User userTable = dbr.Single<User>(t => t.EmailId == EmailId); //userTable.LastLoginTime = d1; lstUser.First().LastLoginTime = d1; dbr.Update <User>(lstUser.First()); _redisCache.Set <User>(lstUser.First().EmailId, lstUser.First()); return(Ok(lstUser.First())); } else { Domain.Socioboard.Models.Googleplusaccounts gplusAcc = Api.Socioboard.Repositories.GplusRepository.getGPlusAccount(Convert.ToString(userinfo["id"]), _redisCache, dbr); if (gplusAcc != null && gplusAcc.IsActive == true) { return(Ok("GPlus account added by other user.")); } Domain.Socioboard.Models.User user = new Domain.Socioboard.Models.User(); if (accType == Domain.Socioboard.Enum.SBAccountType.Free) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Free; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Deluxe) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Deluxe; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Premium) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Premium; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Topaz) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Topaz; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Platinum) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Platinum; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Gold) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Gold; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Ruby) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Ruby; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Standard) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Standard; } user.PaymentType = Domain.Socioboard.Enum.PaymentType.paypal; user.ActivationStatus = Domain.Socioboard.Enum.SBUserActivationStatus.Active; user.CreateDate = DateTime.UtcNow; user.EmailId = EmailId; user.ExpiryDate = DateTime.UtcNow.AddDays(1); user.UserName = "******"; user.EmailValidateToken = "Google"; user.UserType = "User"; user.PaymentStatus = Domain.Socioboard.Enum.SBPaymentStatus.UnPaid; try { user.FirstName = (Convert.ToString(userinfo["name"])); } catch { } user.RegistrationType = Domain.Socioboard.Enum.SBRegistrationType.Google; int SavedStatus = dbr.Add <Domain.Socioboard.Models.User>(user); User nuser = dbr.Single <User>(t => t.EmailId.Equals(user.EmailId)); if (SavedStatus == 1 && nuser != null) { Groups group = new Groups(); group.adminId = nuser.Id; group.createdDate = DateTime.UtcNow; group.groupName = Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName; SavedStatus = dbr.Add <Groups>(group); if (SavedStatus == 1) { Groups ngrp = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.adminId == nuser.Id && t.groupName.Equals(Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName)).FirstOrDefault(); GroupMembersRepository.createGroupMember(ngrp.id, nuser, _redisCache, dbr); // Adding GPlus Profile Api.Socioboard.Repositories.GplusRepository.AddGplusAccount(userinfo, dbr, nuser.Id, ngrp.id, access_token, refreshToken, _redisCache, _appSettings, _logger); } } return(Ok(nuser)); } }
public IHttpActionResult DeleteUserDetails(string user) { GroupsRepository _GroupsRepository = new GroupsRepository(); GroupMembersRepository _GroupMembersRepository = new GroupMembersRepository(); GroupProfileRepository _GroupProfileRepository = new GroupProfileRepository(); TaskRepository _TaskRepository = new TaskRepository(); TaskCommentRepository _TaskCommentRepository = new TaskCommentRepository(); InboxMessagesRepository _InboxMessagesRepository = new InboxMessagesRepository(); FacebookAccountRepository _FacebookAccountRepository = new FacebookAccountRepository(); GoogleAnalyticsAccountRepository _GoogleAnalyticsAccountRepository = new GoogleAnalyticsAccountRepository(); GooglePlusAccountRepository _GooglePlusAccountRepository = new GooglePlusAccountRepository(); InstagramAccountRepository _InstagramAccountRepository = new InstagramAccountRepository(); LinkedInAccountRepository _LinkedInAccountRepository = new LinkedInAccountRepository(); LinkedinCompanyPageRepository _LinkedinCompanyPageRepository = new LinkedinCompanyPageRepository(); ScheduledMessageRepository _ScheduledMessageRepository = new ScheduledMessageRepository(); SocialProfilesRepository _SocialProfilesRepository = new SocialProfilesRepository(); TwitterAccountRepository _TwitterAccountRepository = new TwitterAccountRepository(); TumblrAccountRepository _TumblrAccountRepository = new TumblrAccountRepository(); YoutubeAccountRepository _YoutubeAccountRepository = new YoutubeAccountRepository(); YoutubeChannelRepository _YoutubeChannelRepository = new YoutubeChannelRepository(); try { Domain.Socioboard.Domain.User _User = userrepo.getUserInfoByEmail(user); if (_User != null) { List <Domain.Socioboard.Domain.Groups> lstGroups = _GroupsRepository.getAllGroups(_User.Id); foreach (Domain.Socioboard.Domain.Groups item_group in lstGroups) { int i = _GroupMembersRepository.DeleteGroupMember(item_group.Id.ToString()); int j = _GroupProfileRepository.DeleteAllGroupProfile(item_group.Id); bool rt = _GroupProfileRepository.DeleteGroupReport(item_group.Id); int k = _TaskRepository.DeleteTaskOfGroup(item_group.Id); } int g = _GroupMembersRepository.DeleteGroupMemberByUserId(user); int h = _GroupsRepository.DeleteGroupsByUserid(_User.Id); int l = _TaskCommentRepository.DeleteTaskCommentByUserid(_User.Id); int m = _InboxMessagesRepository.DeleteInboxMessages(_User.Id); int n = _FacebookAccountRepository.DeleteAllFacebookAccount(_User.Id); int o = _GoogleAnalyticsAccountRepository.DeleteGoogleAnalyticsAccountByUserid(_User.Id); int p = _GooglePlusAccountRepository.DeleteGooglePlusAccountByUserid(_User.Id); int q = _InstagramAccountRepository.DeleteInstagramAccountByUserid(_User.Id); int r = _LinkedInAccountRepository.DeleteLinkedInAccountByUserid(_User.Id); int s = _LinkedinCompanyPageRepository.DeleteLinkedinCompanyPage(_User.Id); int t = _ScheduledMessageRepository.DeleteScheduledMessageByUserid(_User.Id); int u = _SocialProfilesRepository.DeleteSocialProfileByUserid(_User.Id); int v = _TwitterAccountRepository.DeleteTwitterAccountByUserid(_User.Id); int w = _TumblrAccountRepository.DeletetumblraccountByUserid(_User.Id); int x = _YoutubeAccountRepository.DeleteYoutubeAccount(_User.Id); int y = _YoutubeChannelRepository.DeleteYoutubeChannelByUserid(_User.Id); int z = userrepo.DeleteUser(_User.Id); } else { return(Ok(false)); } } catch (Exception ex) { return(BadRequest(ex.StackTrace)); } return(Ok(true)); }