Exemple #1
0
 public UserMessage CreateCard(CreateCardCommand command)
 {
     EnsureIsValid(command);
     try
     {
         var cardAccount = _deps.CardAccounts.SurelyFind(command.AccountNo);
         var user = _deps.Users.SurelyFind(command.UserId);
         var cardVendor = _deps.CardVendors.SurelyFind(command.CardVendorId);
         var userCard = _deps.UserCardFactory.Create(
             cardAccount,
             cardVendor,
             user,
             command.CardholderFirstName,
             command.CardholderLastName,
             command.ExpirationDateUtc);
         _deps.UserCards.Create(userCard);
         Commit();
         return UserMessage.ResourceFormat(() => Messages.CardEmitted, userCard.CardNo);
     }
     catch (ServiceException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new ServiceException("Cannot create card.", ex);
     }
 }
 public IHttpActionResult CreateCard(CreateCardCommand command)
 {
     return Ok(_cardAccountService.CreateCard(command));
 }