Esempio n. 1
0
 public IHttpActionResult Block([FromUri]Guid id, SetCardBlockCommand command)
 {
     command.CardId = id;
     return Ok(_cardAccountService.SetCardBlock(command));
 }
Esempio n. 2
0
 public UserMessage SetCardBlock(SetCardBlockCommand command)
 {
     EnsureIsValid(command);
     try
     {
         var userCard = _deps.UserCards.SurelyFind(command.CardId);
         var cardName = userCard.Settings.FriendlyName ?? userCard.CardVendor.Name;
         UserMessage message;
         var events = new List<ApplicationEvent>();
         if (command.Blocked)
         {
             message = UserMessage.ResourceFormat(() => Messages.CardBlocked, cardName);
             userCard.Block();
             events.Add(new UserCardBlocked(userCard.ToModel<UserCard, CustomerCardModel>(), Operation.Id));
         }
         else
         {
             message = UserMessage.ResourceFormat(() => Messages.CardUnblocked, cardName);
             userCard.Unblock();
         }
         Commit();
         events.ForEach(Publish);
         return message;
     }
     catch (ServiceException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new ServiceException("Cannot set card block.", ex);
     }
 }