Пример #1
0
        public async Task <string> Add(AdverModel model)
        {
            var dbModel = _mapper.Map <AdvertDBModel>(model);

            dbModel.Id = new Guid().ToString();
            dbModel.CreationDateTime = DateTime.UtcNow;
            dbModel.Status           = AdvertStatus.Pending;
            using (var client = new AmazonDynamoDBClient())
            {
                using (var context = new DynamoDBContext(client))
                {
                    await context.SaveAsync(dbModel);
                }
            }
            return(dbModel.Id);
        }
Пример #2
0
        public async Task <IActionResult> Create(AdverModel model)
        {
            string recordID;

            try
            {
                recordID = await _advertStorageService.Add(model);
            }
            catch (KeyNotFoundException ex)
            {
                return(new NotFoundResult());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
            return(StatusCode(201, new CreateAdvertResponse {
                Id = recordID
            }));
        }