public async Task <WatcherResponse> UpdateWatcher(UpdateWatcherRequest request) { // Get watcher var watcher = await _watcherRepository.GetSingle(request.WatcherId); // Throw NotFoundException if it does not exist if (watcher == null) { throw new NotFoundException(WatcherMessage.WatcherNotFound); } // Update watcher.Update(request.Buy, request.Sell, request.Enabled); _watcherRepository.Update(watcher); // Save await _mainDbContext.SaveChangesAsync(); // Log into Splunk _logger.LogSplunkRequest(request); // Response var response = _mapper.Map <WatcherResponse>(watcher); // Return return(response); }
public async Task <IActionResult> UpdateWatcher(string watcherId, [FromBody] UpdateWatcherRequest request) { // Reponse request.WatcherId = watcherId; var response = await _watcherService.UpdateWatcher(request); // Return return(Ok(response)); }