Exemplo n.º 1
0
 /// <summary>
 /// Saves a <see cref="User"/> model in persistent database asynchronously.
 /// <remarks>
 /// If this method is consumed, make sure to hook to the <seealso cref="IUserRepository.SaveUserCompleted"/> event of this instance of <see cref="IUserRepository"/>.
 /// </remarks>
 /// </summary>
 /// <param name="user">The <see cref="User"/> instance that needs to be saved in the persistent database.</param>
 void IUserRepository.SaveUserAsync(User user)
 {
     QueueAsyncTask(() =>
     {
         Exception exception = null;
         string message = null;
         try
         {
             //This treachery is for faking a web service call.
             Thread.Sleep(2000);
             SaveUser(user);
             LogUtil.LogInfo("UserRepository",
                             "IUserRepository.SaveUser",
                             string.Format("Successfully saved the user{0}.", user.UserId));
         }
         catch (Exception ex)
         {
             LogUtil.LogError("UserRepository",
                              "IUserRepository.SaveUser", ex);
             exception = ex;
             message = ErrorMessages.ERR_FAILED_TO_SAVE_USER;
         }
         finally
         {
             if (null != _saveUserCompleted)
                 _saveUserCompleted(this, new RepositoryTaskFinishedEventArgs(exception, message));
         }
     });
 }
Exemplo n.º 2
0
 /// <summary>
 /// Saves a <see cref="User"/> model in persistence database.
 /// </summary>
 /// <param name="user">The <see cref="User"/> instance that needs to be saved in the persistence database.</param>
 void IUserRepository.SaveUser(User user)
 {
     SaveUser(user);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Intializes an instance of <see cref="UserViewModel"/>.
 /// </summary>
 /// <param name="user"></param>
 /// <param name="messagingService"> </param>
 public UserViewModel(User user, IMessagingService messagingService)
 {
     if (user == null)
         throw new ArgumentNullException("user");
     if (messagingService == null)
         throw new ArgumentNullException("messagingService");
     _messagingService = messagingService;
     Entity = user;
     //IsUsernameEditable=Entity.UserId <1;
     //Initialize commands
     ChangeImageCommand = new RelayCommand(ChangeImage);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Saves the user in the persistent db.
 /// </summary>
 /// <param name="user"></param>
 private void SaveUser(User user)
 {
     if (user == null)
         throw new ArgumentNullException("user");
     using (var session = SessionProvider.SessionFactory.OpenSession())
     {
         using (var trans = session.BeginTransaction())
         {
             session.SaveOrUpdate(user);
             trans.Commit();
         }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes an instance of <see cref="UserLoggedInEventArgs"/>.
 /// </summary>
 /// <param name="user">The logge in user model.</param>
 public UserLoggedInEventArgs(User user)
 {
     LoggedInUser = user;
 }