public void CreateNewPost(NewPostEntity newPostEntity, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { connection.Execute(SqlCommandStorageService.CreateNewPost(), new { userId = newPostEntity.UserId, topicId = newPostEntity.TopicId, posterIp = newPostEntity.PosterIp, postTime = newPostEntity.PostTime, postMerged = newPostEntity.PostMerged, postReported = newPostEntity.PostReported, enableBbcode = newPostEntity.EnableBbcode, enableSmilies = newPostEntity.EnableSmilies, enableMagicUrl = newPostEntity.EnableMagicUrl, enableSig = newPostEntity.EnableSignature, postSubject = newPostEntity.PostSubject, postText = newPostEntity.PostText, postAttachment = newPostEntity.PostAttachment, postEditTime = newPostEntity.PostEditTime, postEditReason = newPostEntity.PostEditReason, postEditUser = newPostEntity.PostEditUser, postEditCount = newPostEntity.PostEditCount, postEditLocked = newPostEntity.PostEditLocked }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(PostRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } }
public int Insert(UserIdentityEntity user, IConnectionFactory connectionFactory) { var id = 0; try { using (var connection = connectionFactory.Create()) { id = connection.ExecuteScalar <int>(SqlCommandStorageService.UserIdentityRepositoryInsert(), new { userType = user.UserType, userIp = user.UserIp, userBrowser = user.UserBrowser, userRegdate = user.UserRegDate, userEmail = user.Email, userEmailConfirmed = user.EmailConfirmed, passwordHash = user.PasswordHash, securityStamp = user.SecurityStamp, phoneNumber = user.PhoneNumber, phoneNumberConfirmed = user.PhoneNumberConfirmed, twoFactorEnabled = user.TwoFactorEnabled, lockoutEndDateUtc = user.LockoutEndDateUtc, lockoutEnable = user.LockoutEnabled, accessFailedCount = user.AccessFailedCount, userName = user.UserName, userBirthday = user.UserBirthday, userGender = user.UserGender, userLastVisit = user.UserLastVisit, userLastMark = user.UserLastMark, userLastPage = user.UserLastPage, userInactiveReason = user.UserInactiveReason, userInactiveTime = user.UserInactiveTime, userLang = user.UserLang, userTimeZone = user.UserTimeZone, userDateFormat = user.UserDateFormat, userRank = user.UserRank, userNotify = user.UserNotify, userNotify_pm = user.UserNotifyPm, userAvatar = user.UserAvatar, userSignature = user.UserSignature, userFrom = user.UserFrom, userSteam = user.UserSteam, userSkype = user.UserSkype, userIcq = user.UserIcq, userVk = user.UserVk, userFb = user.UserFb, userWebsite = user.UserWebSite, userProfession = user.UserProfession, userInterests = user.UserInterests }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(id); }
public void Insert(UserIdentityEntity user, int groupId, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { connection.Execute(SqlCommandStorageService.UserGroupsIdentityInsert(), new { userId = user.Id, groupId, primaryGroup = true }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserGroupsIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } }
public void Insert(UserIdentityEntity user, UserLoginInfo login, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { connection.Execute(SqlCommandStorageService.UserLoginsIdentityRepositoryInsert(), new { loginProvider = login.LoginProvider, providerKey = login.ProviderKey, userId = user.Id }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserExternalLoginsIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } }
public void Insert(GroupIdentityEntity group, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { connection.Execute(SqlCommandStorageService.GroupIdentityInsert(), new { name = group.Name }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(GroupIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } }
public void Insert(Claim userClaim, int userId, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { connection.Execute(SqlCommandStorageService.UserClaimIsdentityRepositoryInsert(), new { claimValue = userClaim.Value, claimType = userClaim.Type, userId }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserClaimIsdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } }
public void Delete(int userId, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { connection.Execute(SqlCommandStorageService.UserIdentityRepositoryDeleteById(), new { userId }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } }
public int GetGroupId(string groupName, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { return(connection.ExecuteScalar <int>(SqlCommandStorageService.GroupIdentityGetGroupId(), new { name = groupName })); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(GroupIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); return(0); } }
public int FindUserIdByLogin(UserLoginInfo userLogin, IConnectionFactory connectionFactory) { int result = 0; try { using (var connection = connectionFactory.Create()) { result = connection.ExecuteScalar <int>(SqlCommandStorageService.UserLoginsIdentityRepositoryFindUserIdByLogin(), new { loginProvider = userLogin.LoginProvider, providerKey = userLogin.ProviderKey }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserExternalLoginsIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(result); }
public TopicsViewEntity GetTopicById(int topicId, IConnectionFactory connectionFactory) { TopicsViewEntity topicViewEntity = new TopicsViewEntity(); try { using (var connection = connectionFactory.Create()) { topicViewEntity = connection.Query <TopicsViewEntity>(SqlCommandStorageService.GetTopicViewById(), new { topicId }).SingleOrDefault(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(TopicRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(topicViewEntity); }
public List <string> FindByUserId(int userId, IConnectionFactory connectionFactory) { List <string> groupNames = new List <string>(); try { using (var connection = connectionFactory.Create()) { groupNames = connection.Query <string>(SqlCommandStorageService.UserGroupsIdentityFindByUserId(), new { userId }).ToList(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserGroupsIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(groupNames); }
public UserIdentityEntity GetUserByEmail(string email, IConnectionFactory connectionFactory) { UserIdentityEntity userIdentityEntity = new UserIdentityEntity(); try { using (var connection = connectionFactory.Create()) { userIdentityEntity = connection.Query <UserIdentityEntity>(SqlCommandStorageService.UserIdentityRepositoryGetUserByEmail(), new { email }).FirstOrDefault(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(userIdentityEntity); }
public string GetSecurityStamp(int userId, IConnectionFactory connectionFactory) { string securityStamp = String.Empty; try { using (var connection = connectionFactory.Create()) { securityStamp = connection.ExecuteScalar <string>(SqlCommandStorageService.UserIdentityRepositoryGetSecurityStamp(), new { userId }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(securityStamp); }
public List <UserIdentityEntity> GetUserByName(string userName, IConnectionFactory connectionFactory) { List <UserIdentityEntity> userIdentityEntities = new List <UserIdentityEntity>(); try { using (var connection = connectionFactory.Create()) { userIdentityEntities = connection.Query <UserIdentityEntity>(SqlCommandStorageService.UserIdentityRepositoryGetUserByName(), new { userName }).ToList(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(userIdentityEntities); }
public int GetUserId(string userName, IConnectionFactory connectionFactory) { int userId = 0; try { using (var connection = connectionFactory.Create()) { userId = connection.ExecuteScalar <int>(SqlCommandStorageService.UserIdentityRepositoryGetUserId(), new { userName }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(userId); }
public ForumsViewEntity GetForumInfoById(int forumId, IConnectionFactory connectionFactory) { ForumsViewEntity forumsViewEntity = new ForumsViewEntity(); try { using (var connection = connectionFactory.Create()) { forumsViewEntity = connection.Query <ForumsViewEntity>(SqlCommandStorageService.GetForumViewInfoById(), new { forumId }).SingleOrDefault(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(ForumsViewRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(forumsViewEntity); }
public int GetForumIdByTopicId(int topicId, IConnectionFactory connectionFactory) { int forumId = 0; try { using (var connection = connectionFactory.Create()) { forumId = connection.ExecuteScalar <int>(SqlCommandStorageService.GetForumIdByTopicId(), new { topicId }); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(ForumsViewRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(forumId); }
public List <PollOptionEntity> GetPollOptionsByPollsId(List <int> pollIdList, IConnectionFactory connectionFactory) { List <PollOptionEntity> pollOptionEntities = new List <PollOptionEntity>(); try { using (var connection = connectionFactory.Create()) { pollOptionEntities = connection.Query <PollOptionEntity>(SqlCommandStorageService.GetPollOptionsByPollsId(), new { pollIdList }).ToList(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(PollOptionRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(pollOptionEntities); }
public List <ForumsViewEntity> GetAllForums(IConnectionFactory connectionFactory) { List <ForumsViewEntity> forumsViewEntities = new List <ForumsViewEntity>(); try { using (var connection = connectionFactory.Create()) { forumsViewEntities = connection.Query <ForumsViewEntity>(SqlCommandStorageService.GetAllForumsView()).ToList(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(ForumsViewRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(forumsViewEntities); }
public GroupIdentityEntity GetGroupByName(string groupName, IConnectionFactory connectionFactory) { GroupIdentityEntity groupIdentityEntity = new GroupIdentityEntity(); try { using (var connection = connectionFactory.Create()) { groupIdentityEntity = connection.Query <GroupIdentityEntity>(SqlCommandStorageService.GroupIdentityGetGroupByName(), new { nane = groupName }).SingleOrDefault(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(GroupIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(groupIdentityEntity); }
public List <IdentityPermissionEntity> GetSeveralPermissionsByUserId(List <string> permissionsTitleList, int userId, IConnectionFactory connectionFactory) { List <IdentityPermissionEntity> identityPermissionEntities = new List <IdentityPermissionEntity>(); try { List <UserPermissionEntity> userPermissionEntities; List <GroupPermissionEntity> groupPermissionEntities; using (var connection = connectionFactory.Create()) { List <int> groupsId = connection.Query <int>(SqlCommandStorageService.GetUserGroupsId(), new { userId }).ToList(); userPermissionEntities = connection.Query <UserPermissionEntity>( SqlCommandStorageService.GetUserSeveralPermissionsByUserIdAndPermissionName(), new { permissionsTitleList, userId }).ToList(); groupPermissionEntities = connection.Query <GroupPermissionEntity>( SqlCommandStorageService.GetGroupsSeveralPermissionsByGroupsIdAndPermissionName(), new { permissionsTitleList, groupsId }).ToList(); } foreach (var userPermissionEntity in userPermissionEntities) { userPermissionEntity.Type = IdentityPermissionType.UserPermission; identityPermissionEntities.Add(userPermissionEntity); } foreach (var groupPermissionEntity in groupPermissionEntities) { groupPermissionEntity.Type = IdentityPermissionType.GroupPermission; identityPermissionEntities.Add(groupPermissionEntity); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(IdentityPermissionRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(identityPermissionEntities); }
public List <ReadPostEntity> GetAllPostsByTopicId(int topicId, IConnectionFactory connectionFactory, int onPage, int?page) { List <ReadPostEntity> postEntities = new List <ReadPostEntity>(); try { if (page == null || page < 1) { page = 1; } using (var connection = connectionFactory.Create()) { postEntities = connection.Query <ReadPostEntity>(SqlCommandStorageService.GetPostsByTopicId(), new { topicId, onPage, page }).ToList(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(PostRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(postEntities); }
public List <TopicsViewEntity> GetTopicsByForumId(int forumId, IConnectionFactory connectionFactory, int onPage, int?page) { List <TopicsViewEntity> topicViewEntities = new List <TopicsViewEntity>(); try { if (page == null || page < 1) { page = 1; } using (var connection = connectionFactory.Create()) { topicViewEntities = connection.Query <TopicsViewEntity>(SqlCommandStorageService.GetAllTopicsViewByForumId(), new { forumId, page, onPage }).ToList(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(TopicRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(topicViewEntities); }
public bool DeletePost(int postId, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { connection.Execute(SqlCommandStorageService.AdminDeletePost(), new { postId }); var validator = connection.ExecuteScalar <int>(SqlCommandStorageService.AdminCheckPost(), new { postId }); if (validator == 0) { return(true); } return(false); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(PostRepository)}. Error in function {DemLogger.GetCallerInfo()}"); return(false); } }
public bool UnbanUser(int userId, IConnectionFactory connectionFactory) { try { using (var connection = connectionFactory.Create()) { var validator = connection.ExecuteScalar <int>(SqlCommandStorageService.CheckIsUserBanned(), new { userId }); if (validator == 0) { return(false); } connection.Execute(SqlCommandStorageService.UnbanUser(), new { userId }); validator = connection.ExecuteScalar <int>(SqlCommandStorageService.CheckIsUserBanned(), new { userId }); return(validator == 0); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); return(false); } }
public ClaimsIdentity FindByUserId(int userId, IConnectionFactory connectionFactory) { ClaimsIdentity claims = new ClaimsIdentity(); try { using (var connection = connectionFactory.Create()) { List <ClaimIdentityEntity> claimIdentityEntities = connection.Query <ClaimIdentityEntity>(SqlCommandStorageService.UserClaimIsdentityRepositoryFindByUserId(), new { userId }).ToList(); foreach (var claimIdentityEntity in claimIdentityEntities) { claims.AddClaim(new Claim(claimIdentityEntity.ClaimType, claimIdentityEntity.ClaimValue)); } } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserClaimIsdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(claims); }
public List <UserForPostViewEntity> GetUsersForPostsByUsersId(IConnectionFactory connectionFactory, List <int> usersId) { List <UserForPostViewEntity> userForPostViewEntities = new List <UserForPostViewEntity>(); try { using (var connection = connectionFactory.Create()) { userForPostViewEntities = connection.Query <UserForPostViewEntity>(SqlCommandStorageService.GetUsersForPostsViewByUsersId(), new { usersId }).ToList(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(PostRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(userForPostViewEntities); }
public List <UserLoginInfoIdentityEntity> FindByUserId(int userId, IConnectionFactory connectionFactory) { List <UserLoginInfoIdentityEntity> userLoginInfoIdentityEntities = new List <UserLoginInfoIdentityEntity>(); try { using (var connection = connectionFactory.Create()) { userLoginInfoIdentityEntities = connection.Query <UserLoginInfoIdentityEntity>(SqlCommandStorageService.UserLoginsIdentityRepositoryFindByUserId(), new { userId }).ToList(); } } catch (Exception exception) { DemLogger.Current.Error(exception, $"{nameof(UserExternalLoginsIdentityRepository)}. Error in function {DemLogger.GetCallerInfo()}"); } return(userLoginInfoIdentityEntities); }