Ejemplo n.º 1
0
 public UserBriefModel CreateUser(CreateUserCommand command)
 {
     EnsureIsValid(command);
     try
     {
         var user = command.ToEntity <CreateUserCommand, User>();
         _deps.Users.Create(user);
         if (!user.IsAdmin)
         {
             var paymentProfile = _deps.UserPaymentProfileFactory.Create(user, command.Address, command.FullName);
             _deps.PaymentProfiles.Create(paymentProfile);
         }
         Commit();
         return(user.ToModel <User, UserBriefModel>());
     }
     catch (Exception ex)
     {
         throw new ServiceException("Can't create user.", ex);
     }
 }