/// <summary> /// Check if a given password is correct /// </summary> /// <param name="user">the user to check</param> /// <param name="password">real password</param> /// <returns>treu is mach else throw exeption</returns> public bool IsCorrectPassword(BO.User user, string password) { if (user.HashedPassword == GetHashPassword(password)) { return(true); } throw new BO.BadUsernameException(user.UserName, "Not valid password"); }
/// <summary> /// Add new User to my the Data Source /// </summary> /// <param name="newUser"></param> public void AddUser(BO.User newUser) { var userDo = newUser.CopyPropertiesToNew(typeof(DO.User)) as DO.User; try { dl.AddUser(userDo); } catch (DO.BadUsernameException ex) { throw new BO.BadUsernameException(newUser.UserName, ex.Message); } }
/// <summary> /// Gets a single user by a given Username /// </summary> /// <param name="userName">a given username, the entity key</param> /// <returns>User of BO</returns> public BO.User GetUser(string userName) { BO.User userBo = new BO.User(); DO.User userDo; try { userDo = dl.GetUser(userName); userDo.CopyPropertiesTo(userBo); } catch (DO.BadUsernameException ex) { throw new BO.BadUsernameException(userName, ex.Message); } return(userBo); }