public async Task <IActionResult> GetOrCreateDefaultViewAsync() { var customerId = _membership.GetCustomerId(User); var view = await _persistence.Views.GetForCustomerAsync(customerId); if (view == null) { view = await CreateDefaultViewAsync(customerId); } return(Ok(new ViewConfigurationModel(view))); }
public async Task <IActionResult> GetClientsAsync() { var customerId = _membership.GetCustomerId(User); var clients = await _persistence.EventEntries.GetAllClientsAsync(customerId); var results = clients.Select(c => new ClientListItem(c.Id, c.UUID, c.Name)) .ToList(); return(Ok(results)); }
public async Task <IActionResult> GetEventAsync(string clientId, Guid entryId) { if (!ModelState.IsValid) { return(BadRequest(new ApiError(400, ModelState))); } var customerId = _membership.GetCustomerId(User); var eventEntryId = new EventEntryId(entryId); var entry = await _persistence.EventEntries.GetAsync(customerId, eventEntryId); if (entry == null) { return(NotFound(new ApiError(404, "Specified event not found"))); } var recordedEntry = new RecordedEvent(entry, "/api/v1/entries/"); return(Ok(recordedEntry)); }