public async ValueTask PostAsync(UsageRecord usageRecord) { await _repository.UsageRecords.AddAsync(usageRecord); await _repository.SaveChangesAsync(); await PublishPersisientEventAsync(usageRecord, UsageRecordsChangeEventKind.Add); }
public async ValueTask <IActionResult> PostActiveAsync(string no) { Project?project = await _repository.Projects.FindAsync(no); if (project is not null) { await _repository.ActiveProjectIndices.AddAsync(new() { No = project.No }); await _repository.SaveChangesAsync(); return(Ok()); } else { return(NotFound($"{no} is not a valid project no.")); } }
public async ValueTask <ActionResult> PostAsync(UsageRecord usageRecord) { if (Validate(usageRecord)) { await _usageRecordsRepository.UsageRecords.AddAsync(usageRecord); // usageRecord doesn't get its id until AddAsync method, this line can't appear before! _ = _elasticSearch.IndexAsync(usageRecord).ConfigureAwait(false); await _usageRecordsRepository.SaveChangesAsync(); return(Ok()); } else { return(BadRequest("Invalid usage record was posted")); } }