3

I am trying to give users the ability to change their display name which happens to be in IAuthSession interface and commit the change to the database.

I register a container via the AppHost:

container.Register<IUserAuthRepository>(new MongoDBAuthRepository(new MongoDBClient().MongoDB, true)); 

Then in my service I do the following:

public class HandlerService : Service
{
    public HandlerService(IUserAuthRepository userAuthRepository)
    {
        this._userAuthRepository = userAuthRepository;
    }

    private readonly IUserAuthRepository _userAuthRepository;

    public void SaveDisplayName(string displayName) {
        var session = base.SessionAs<CustomUserSession>(); // CustomUserSession inherits AuthUserSession
        if (!session.DisplayName.EqualsIgnoreCase(displayName))
        {
            session.DisplayName = displayName;
            _userAuthRepository.SaveUserAuth(session);
        }
    }
}

Although the code hits _userAuthRepository.SaveUserAuth, no exception is raised and nothing is returned since the method is void. However the data does not actually get committed to the Database. In this particular case MongoDB.

Any ideas why it is not saving it or why no exceptions are thrown if there was a problem?

Scott
  • 21,211
  • 8
  • 65
  • 72
Val
  • 1,023
  • 3
  • 10
  • 21

0 Answers0