public async Task Confirm(ConfirmAdvertisementModel model) { using (var client = new AmazonDynamoDBClient()) { using (var context = new DynamoDBContext(client)) { var record = await context.LoadAsync <AdvertisementDbModel>(model.Id); if (record is null) { throw new KeyNotFoundException($"A record wit Id = { model.Id } was not found"); } if (model.Status == AdvertisementStatus.Active) { record.Status = AdvertisementStatus.Active; await context.SaveAsync(record); } else { await context.DeleteAsync(record); } } } }
public async Task <IActionResult> Confirm(ConfirmAdvertisementModel model) { try { await _advertisementStorageService.Confirm(model); return(NoContent()); } catch (KeyNotFoundException) { return(new NotFoundResult()); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }