public async Task <ActionResult> Rename(Guid rootId, [FromBody] RenameContact model) { var cmd = new Domain.Types.PersonalName(model.Given, model.Middle, model.Family) .Apply(x => new Domain.Aggregates.RenameContact(rootId, model.OriginalVersion, x)); var sent = _bus.Send(cmd); var result = await cmd.Result.Wait(); return(result.Value.Match( Right: _ => Ok(), // TODO: don't bubble up any native exception messages Left: error => BadRequest(error) as ActionResult)); }
public async Task <ActionResult> Create(CreateContact model) { var cmd = new Domain.Types.PersonalName(model.Given, model.Middle, model.Family) .Apply(x => new Domain.Aggregates.CreateContact(x)); var sent = _bus.Send(cmd); var result = await cmd.Result.Wait(); return(result.Value.Match( Right: _ => CreatedAtAction(nameof(GetByRootId), new { rootId = cmd.RootId }, null), // TODO: don't bubble up any native exception messages Left: error => BadRequest(error) as ActionResult)); }