public async Task <IActionResult> FetchCitizen(CancellationToken cancellationToken, string id = null) { if (id == null) { return(BadRequest("Must include id")); } var citizen = await FoundationDbConnector.Get <Citizen>(id, cancellationToken); return(Ok(citizen)); }
public async Task <IActionResult> CreateCitizen([FromBody] Citizen citizen, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(citizen.Uuid)) { do { citizen.Uuid = _idGenerator.GenerateUuid(); } while (!await _idGenerator.IsUnique(citizen.Uuid)); } await FoundationDbConnector.Set(citizen.Uuid, citizen, cancellationToken); return(Ok(new CreateCitizenResponse(citizen.Uuid))); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { Fdb.Start(600); var fdbConnection = Fdb.OpenAsync().GetAwaiter().GetResult(); var emitterUrl = env.IsDevelopment() ? "localhost:5000" : "Insert production url here"; FoundationDbConnector.Initialize(fdbConnection); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); }