Example #1
0
 public IHttpActionResult UpdateSettings([FromUri]Guid id, UpdateCardSettingsCommand command)
 {
     command.CardId = id;
     return Ok(_cardAccountService.UpdateCardSettings(command));
 }
Example #2
0
 public UserMessage UpdateCardSettings(UpdateCardSettingsCommand command)
 {
     EnsureIsValid(command);
     try
     {
         var events = new List<ApplicationEvent>();
         var userCard = _deps.UserCards.SurelyFind(command.CardId);
         if (!string.IsNullOrEmpty(command.FriendlyName))
         {
             userCard.Settings.FriendlyName = command.FriendlyName;
         }
         if (command.CardLimits != null)
         {
             Mapper.Map(command.CardLimits, userCard.Settings.Limits);
             events.Add(new UserCardLimitChanged(userCard.ToModel<UserCard, CustomerCardModel>(), Operation.Id));
         }
         Commit();
         events.ForEach(Publish);
         return UserMessage.Resource(() => Messages.CardSettingsUpdated);
     }
     catch (ServiceException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new ServiceException("Cannot update card settings.", ex);
     }
 }