예제 #1
0
        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));
        }
예제 #2
0
        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();
        }
예제 #3
0
        public async Task <ActionResult> Put([FromBody] AlterationViewModel viewModel)
        {
            if (viewModel == null)
            {
                return(BadRequest());
            }

            await _alterationService.ChangeAlterationAsync(viewModel.ToDomainModel());

            return(Ok());
        }
예제 #4
0
        public async Task <ActionResult> Create(AlterationViewModel alteration)
        {
            try
            {
                var service = new AlteringService(_configuration);
                await service.Create(alteration);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
예제 #5
0
        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());
        }
예제 #6
0
        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));
 }