public static Alteration ToDomainModel(this AlterationViewModel alterationViewModel) { var rightShortenValue = new ShortenValue(alterationViewModel.RightShortenValue); var leftShortenValue = new ShortenValue(alterationViewModel.LeftShortenValue); return(new Alteration(alterationViewModel.Id, alterationViewModel.CustomerId, alterationViewModel.SuitType, rightShortenValue, leftShortenValue)); }
async public Task Create(AlterationViewModel alteration) { var uri = $"{_alteringServiceUrl}"; var alterationContent = new StringContent(JsonConvert.SerializeObject(alteration), System.Text.Encoding.UTF8, "application/json"); var response = await _httpClient.PostAsync(uri, alterationContent); response.EnsureSuccessStatusCode(); }
public async Task <ActionResult> Put([FromBody] AlterationViewModel viewModel) { if (viewModel == null) { return(BadRequest()); } await _alterationService.ChangeAlterationAsync(viewModel.ToDomainModel()); return(Ok()); }
public async Task <ActionResult> Create(AlterationViewModel alteration) { try { var service = new AlteringService(_configuration); await service.Create(alteration); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Put(Guid id, [FromBody] AlterationViewModel viewModel) { if (viewModel == null) { return(BadRequest()); } //This httpput exists to be used to create a message for AlterationFinished in serviceBus if (viewModel.AlterationStatus == Domain.Aggregates.AlterationAggregate.AlterationStatus.Paid) { var @event = new AlterationFinishedIntegrationEvent(viewModel.Id, viewModel.CustomerId); _eventBus.Publish(@event); } return(Ok()); }
public async Task <ActionResult> Post([FromBody] AlterationViewModel viewModel) { if (viewModel == null) { return(BadRequest()); } var alterationOrder = await _alterationService.CreateAlterationAsync(viewModel.ToDomainModel()); var @event = new OrderCreatedIntegrationEvent(alterationOrder.Id, alterationOrder.CustomerId); _eventBus.Publish(@event); return(Ok(alterationOrder.ToViewModel())); }
string BuildChangeAlterationRequest(AlterationViewModel alteration) { return(JsonConvert.SerializeObject(alteration)); }