Ejemplo n.º 1
0
 /// <summary>
 /// Inserts a new role for a user in the UserRoles table
 /// </summary>
 /// <param name="user">The User</param>
 /// <param name="roleId">The Role's id</param>
 /// <returns></returns>
 public void Insert(User user, int roleId)
 {
     using (var conn = db.GetOpenConnection())
     {
         conn.Execute(@"INSERT INTO UserRole (UserID, RoleID) VALUES (@userId, @roleId)",
             new { userId = user.Id, roleId = roleId });
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Deletes a login from a user in the UserLogins table
 /// </summary>
 /// <param name="user">User to have login deleted</param>
 /// <param name="login">Login to be deleted from user</param>
 /// <returns></returns>
 public void Delete(User user, UserLogin login)
 {
     using (var conn = db.GetOpenConnection())
     {
         conn.Execute(@"DELETE FROM UserLogin WHERE UserID = @userId AND LoginProvider = @loginProvider AND ProviderKey = @providerKey",
             new
             {
                 userId = user.Id,
                 loginProvider = login.LoginProvider,
                 providerKey = login.ProviderKey
             });
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Inserts a new login in the UserLogins table
 /// </summary>
 /// <param name="user">User to have new login added</param>
 /// <param name="login">Login to be added</param>
 /// <returns></returns>
 public void Insert(User user, UserLogin login)
 {
     using (var conn = db.GetOpenConnection())
     {
         conn.Execute(@"INSERT INTO UserLogin (LoginProvider, ProviderKey, UserID) 
                             VALUES (@loginProvider, @providerKey, @userId)",
                 new
                 {
                     loginProvider = login.LoginProvider,
                     providerKey = login.ProviderKey,
                     userId = user.Id
                 });
     }
 }
Ejemplo n.º 4
0
		public void Update(User user)
		{
			using (var conn = db.GetOpenConnection())
			{
				if (user.UpdatedByUserID.HasValue && user.UpdatedByUserID == 0)
					user.UpdatedByUserID = null;

				var parameters = new DynamicParameters(user);
				
				string sql = @" UPDATE [User] 
								SET UserName = @Email,
									Email = @Email,
									FirstName = @FirstName,
									LastName = @LastName,
									Gender = @Gender,
									DegreeID = @DegreeID,
									City = @City,
									CountryID = @CountryID,
									EmailConfirmed = @EmailConfirmed, 
									PasswordHash = @PasswordHash,
									SecurityStamp = @SecurityStamp,
									PhoneNumber = @PhoneNumber,
									PictureUrl = @PictureUrl,
									PhoneNumberConfirmed = @PhoneNumberConfirmed,
									TwoFactorEnabled = @TwoFactorEnabled,  
									LockoutEnabled = @LockoutEnabled,
									LockoutEndDateUtc = @LockoutEndDateUtc,
									AccessFailedCount = @AccessFailedCount,
									UpdatedDateUtc = GETUTCDATE(),
									UpdatedByUserID = @UpdatedByUserID
								WHERE UserID = @UserID";

				conn.Execute(sql, parameters);
			}
		}
Ejemplo n.º 5
0
		public int Insert(User user)
		{
			using (var conn = db.GetOpenConnection())
			{
				var parameters = new DynamicParameters(user);

				string sql = @" INSERT INTO [User]
										(UserName, Email, FirstName, LastName, Gender, DegreeID, 
										City, CountryID, EmailConfirmed, PasswordHash, SecurityStamp, 
										PhoneNumber, PictureUrl, PhoneNumberConfirmed, TwoFactorEnabled, 
										LockoutEnabled, LockoutEndDateUtc, AccessFailedCount)
								VALUES  (@Email, @Email, @FirstName, @LastName ,@Gender, @DegreeID, 
										@City, @CountryID, @EmailConfirmed, @PasswordHash, @SecurityStamp, 
										@PhoneNumber, @PictureUrl, @PhoneNumberConfirmed, @TwoFactorEnabled, 
										@LockoutEnabled, @LockoutEndDateUtc, @AccessFailedCount);
								SELECT Cast(SCOPE_IDENTITY() AS INT)";

				var id = conn.ExecuteScalar<int>(sql, parameters);

				user.UserID = id;

				return id;
			}
		}
Ejemplo n.º 6
0
 public ArticleReviewer()
 {
     Reviewer = new User();
     Template = new ReviewTemplate();
     ReviewStatus = new ReviewStatus();
 }
Ejemplo n.º 7
0
 public void UpdateUser(User user)
 {
     throw new NotImplementedException();
 }