public async Task <ActionResult <Merchant> > AddMerchant([FromQuery] string merchant_name) { Merchant merchant = new Merchant(); merchant.Name = merchant_name; var resp = await _merchantRepository.AddAsync(merchant); return(Ok(resp)); }
protected override async Task CustomSeedAsync() { var merchant1 = new Merchant("Amazon", "PiggyBank"); var merchant2 = new Merchant("Netflix", "PiggyBank"); var merchant3 = new Merchant("Apple", "OtherAquirer"); var merchants = new List <Merchant> { merchant1, merchant2, merchant3 }; await Task.WhenAll(merchants.Select(x => _merchantRepository .AddAsync(x))); }
public async Task HandleAsync(UserCreated @event) { try { var merchant = new Merchant(); merchant.UserId = @event.UserId; merchant.Name = @event.Name; merchant.AcquiringBank = @event.AcquirerName; await _merchantRepository.AddAsync(merchant); var logCreated = new CreateLog(@event.UserId, Guid.Empty, LogLevel.Info, "Merchant_Created", "Created merchant " + @event.Name); await _busClient.PublishAsync(logCreated); } catch (Exception ex) { var logCreated = new CreateLog(@event.UserId, Guid.Empty, LogLevel.Error, "Merchant_Creation_Error", "Cannot save Merchant because :" + ex.Message); await _busClient.PublishAsync(logCreated); } }