public async Task <string> AddAsync(Models.AdvertModel model) { var dbModel = _mapper.Map <AdvertDataModel>(model); dbModel.Id = Guid.NewGuid().ToString(); dbModel.CreateDate = DateTime.UtcNow; dbModel.Status = AdvertStatus.Pending; using (var client = new AmazonDynamoDBClient()) { using (var context = new DynamoDBContext(client)) { await context.SaveAsync(dbModel); } } return(dbModel.Id); }
public async Task <IActionResult> CreateAsync(Models.AdvertModel model) { string recordId; try { recordId = await _advertStorageService.AddAsync(model); } catch (KeyNotFoundException) { return(new NotFoundResult()); } catch (Exception exception) { return(StatusCode(500, exception)); } return(StatusCode(201, new CreateAdvertResponse { Id = recordId })); }