public CreateAccountView()
 {
     InitializeComponent();
     State = CreateAccountState.None;
     Model = new CreateAccountInfo();
     SetDataBindings();
 }
 public void CreateAccount(CreateAccountInfo item)
 {
     try
     {
         var user = User.Create(item.Name, item.Password);
         user.Profile.FirstName = item.FirstName;
         user.Profile.LastName = item.LastName;
         var info = AppContext
             .GetObject<IValidator<User>>()
             .Validate(user);
         if (!info.IsValid)
             throw new ValidationException(info);
         using (var uow = AppContext.GetObject<IUnitOfWork>())
         {
             AppContext
                 .GetObject<IUserRepository>()
                 .Add(user);
             uow.Complete();
         }
         AppContext.User = new GenericPrincipal(
             new GenericIdentity(item.Name),
             new string[] { });
     }
     catch (UserException ex)
     {
         throw new CreateAccountFailedException(ex.Message, ex);
     }
 }