public async Task Handle(UpdateClient command) { var client = await Clients.FindAsync(command.Id); client.Update(command.Data); dbContext.Update(client); await dbContext.SaveChangesAsync(); await eventBus.Publish(new ClientUpdated(command.Id, command.Data)); }
public async Task <Unit> Handle(UpdateClient command, CancellationToken cancellationToken = default) { var client = await clients.FindAsync(command.Id); client.Update(command.Data); dbContext.Update(client); await SaveAndPublish(client, cancellationToken); return(Unit.Value); }
public async Task Handle(UpdateClient command, CancellationToken cancellationToken = default(CancellationToken)) { var client = await Clients.FindAsync(command.Id); client.Update(command.Data); dbContext.Update(client); await dbContext.SaveChangesAsync(cancellationToken); await eventBus.Publish(new ClientUpdated(command.Id, command.Data)); }
public IActionResult Save(Client cli) { if (cli.Id == 0) { ctx.Add(cli); } else { ctx.Update(cli); } ctx.SaveChanges(); return(View()); // return RedirectToAction("Index"); }
public async Task <TEntity> UpdateAsync(TEntity entity) { if (entity == null) { throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null"); } try { _context.Update(entity); await _context.SaveChangesAsync(); return(entity); } catch (Exception ex) { throw new Exception($"{nameof(entity)} could not be updated: {ex.Message}"); } }