public async Task Confirm(ConfirmAvertModel model) { using (var client = new AmazonDynamoDBClient()) { using (var context = new DynamoDBContext(client)) { var record = await context.LoadAsync <AdvertDBModel>(model.Id); if (record == null) { throw new KeyNotFoundException($"A record with ID={model.Id} was not found."); } if (model.Status == AdvertStatus.Active) { record.Status = AdvertStatus.Active; await context.SaveAsync(record); } else { await context.DeleteAsync(record); } } } }
public async Task <IActionResult> Confirm(ConfirmAvertModel model) { try { await _advertStorageService.Confirm(model); } catch (KeyNotFoundException) { return(new NotFoundResult()); } catch (Exception e) { return(StatusCode(500, e.Message)); } return(new OkResult()); }