public async Task <IActionResult> Confirm(ConfirmAdvertModel model) { try { await _advertStorageService.ConfirmAsync(model); await RaiseAdvertConfirmedMessage(model); } catch (KeyNotFoundException) { return(new NotFoundResult()); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } return(new OkResult()); }
public async Task <IActionResult> Confirm(ConfirmAdvertModel model) { try { await advertStorageService.Confirm(model); await RaiseAdvertConfirmMessage(model); } catch (KeyNotFoundException) { return(new NotFoundResult()); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } return(new OkResult()); }
public async Task ConfirmAsync(ConfirmAdvertModel model) { DynamoDBContext 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(ConfirmAdvertModel confirmAdvert) { try { await _advertStorageService.ConfirmAsync(confirmAdvert); // await RaiseAdvertConfirmedMessage(confirmAdvert); } catch (KeyNotFoundException) { return(new NotFoundResult()); } catch (Exception exception) { return(StatusCode(500, exception.Message)); } return(new OkResult()); }
public async Task Confirm(ConfirmAdvertModel model) { using (var context = new DynamoDBContext(_amazonDynamoDB)) { var record = await context.LoadAsync <AdvertDTO>(model.ID); if (record == null) { throw new Exception("record not found"); } if (record.Status == AdvertStatus.Success) { await context.SaveAsync(record); } else { await context.DeleteAsync(model.ID); } } }
public async Task <IActionResult> Confirm(ConfirmAdvertModel model) { string recordid; try { await _AdvertStorageServicecs.Confirm(model); } catch (KeyNotFoundException) { return(new NotFoundResult()); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } return(new OkResult()); }
private async Task RaiseAdvertConfirmedMessage(ConfirmAdvertModel model) { using (var client = new AmazonSimpleNotificationServiceClient(Amazon.RegionEndpoint.USEast2)) { var topicArn = confirguration.GetValue <string>("TopicArn"); var dbModel = await _advertService.GetById(model.Id); var message = new AdvertConfirmMessage { Id = model.Id, Title = dbModel.Title, Description = dbModel.Description, FilePath = dbModel.FilePath, Price = dbModel.Price, UserName = dbModel.Username }; var msgJson = JsonConvert.SerializeObject(message); await client.PublishAsync(topicArn, msgJson); } }
private async Task RaiseAdvertConfirmedMessage(ConfirmAdvertModel model) { using (AmazonSimpleNotificationServiceClient client = new AmazonSimpleNotificationServiceClient()) { string topicArn = Configuration.GetValue <string>("TopicArn"); string dbModelTitle = await _advertStorageService.GetById(model.Id); AdvertConfirmedMessage message = new AdvertConfirmedMessage { Id = model.Id, Title = dbModelTitle }; await testMessage(message.ToString()); var messageJson = JsonConvert.SerializeObject(message); await client.PublishAsync(topicArn, messageJson); } }
public async Task ConfirmAsync(ConfirmAdvertModel confirmAdvert) { using (var client = new AmazonDynamoDBClient()) { using (var context = new DynamoDBContext(client)) { var record = await context.LoadAsync<AdvertForCreationDto>(confirmAdvert.Id); if (record == null) throw new KeyNotFoundException($"A record with ID={confirmAdvert.Id} was not found."); if (confirmAdvert.Status == AdvertStatus.Active) { record.FilePath = confirmAdvert.FilePath; record.Status = AdvertStatus.Active; await context.SaveAsync(record); } else { await context.DeleteAsync(record); } } } }
public async Task Confirm(ConfirmAdvertModel model) { using (var ctx = new DynamoDBContext(_client)) { var record = await ctx.LoadAsync <AdvertDbModel>(model.Id); if (record == null) { throw new KeyNotFoundException($"A record with Id={model.Id} was not found."); } if (model.Status == AdvertStatus.Active) { await UpdateAdvertAsActive(ctx, record); } else { await DeleteAdvert(ctx, record); } } }
public async Task Confirm(ConfirmAdvertModel model) { //using (var context = new DynamoDBContext(_amazonDynamoDB)) //{ var record = await _dynamoDBContext.LoadAsync <AdvertDbModel>(model.Id); if (record == null) { throw new KeyNotFoundException($"A record with ID={model.Id} was not found."); } if (model.AdvertStatus == AdvertStatus.Active) { record.AdvertStatus = AdvertStatus.Active; await _dynamoDBContext.SaveAsync(record); } else { await _dynamoDBContext.DeleteAsync(record); } //} }
public async Task Confirm(ConfirmAdvertModel 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("Record With" + model.Id + "Not found"); } if (model.Status == AdvertStatus.Active) { record.Status = AdvertStatus.Active; await context.SaveAsync(record); } else { await context.DeleteAsync(record); } } } }
public async Task ConfirmAsync(ConfirmAdvertModel 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.Confirmed; record.FilePath = model.FilePath; await context.SaveAsync(record); } else { await context.DeleteAsync(record); } }
public async Task <bool> Confirm(ConfirmAdvertModel model) { model.Status = AdvertStatus.Active; using (var client = new AmazonDynamoDBClient()) { using (var context = new DynamoDBContext(client)) { var record = await context.LoadAsync <AdvertDBModel>(model.Id); if (model.Status == AdvertStatus.Active) { record.Status = AdvertStatus.Active; await context.SaveAsync(record); } else { await context.DeleteAsync(record); } } } return(true); }
public async Task <bool> Confirm(ConfirmAdvertModel model) { //using AmazonDynamoDBClient client = new(); using DynamoDBContext context = new(_amazonDynamoDBClient); AdvertDbModel dbModel = await context.LoadAsync <AdvertDbModel>(model.Id); if (dbModel == null) { throw new KeyNotFoundException($"A Record with id={model.Id} was not found"); } if (model.Status == AdvertStatus.Active) { dbModel.AdvertStatus = model.Status; await context.SaveAsync(dbModel); return(true); } else { await context.DeleteAsync(dbModel); return(false); } }
public async Task Confirm(ConfirmAdvertModel model) { using (var client = new AmazonDynamoDBClient()) { using (var context = new DynamoDBContext(client)) { var entity = await context.LoadAsync <AdvertEntity>(model.Id); if (entity == null) { throw new KeyNotFoundException("Id not found"); } if (model.Status == AdvertStatus.Active) { entity.Status = AdvertStatus.Active; await context.SaveAsync(entity); } else { await context.DeleteAsync(model); } } } }
public async Task <IActionResult> Confirm(string id, [FromBody] ConfirmAdvertModel model) { var confirmModel = new ConfirmAdvertModel { Id = id, Status = model.Status }; try { await _advertStorageService.Confirm(confirmModel); await RaiseConfirmedAdvertMessage(confirmModel); } catch (KeyNotFoundException e) { return(NotFound(new { message = e.Message })); } catch (Exception e) { return(StatusCode(500, e.Message)); } return(StatusCode(200)); }
public async Task ConfirmModel(ConfirmAdvertModel 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.Approved) { record.Status = AdvertStatus.Approved; await context.SaveAsync(record); } else { await context.DeleteAsync(record); } } } }
public async Task Delete(ConfirmAdvertModel model) => await Run(async (DynamoDBContext context) => { var record = await context.LoadAsync <AdvertDbModel>(model.Id); await context.DeleteAsync(record); });
public Task <bool> Confirm(ConfirmAdvertModel model) { return(Task.FromResult(true)); }
public Task <ActionResult> Confirm([FromBody] ConfirmAdvertModel model) => GetReponse( async() => await _advertsService.Confirm(model, _configuration.GetValue <string>("TopicArn")));
public Task Confirm(ConfirmAdvertModel model) { throw new NotImplementedException(); }
public Task <bool> Confirm(ConfirmAdvertModel model) { throw new System.NotImplementedException(); }