Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateAsync(int id)
        {
            var query = new GetTourByIdQuery
            {
                Id = id
            };

            var result = await _mediator.Send(query);

            if (result.Failure)
            {
                ModelState.AddModelError(string.Empty, result.Error);

                return(BadRequest(ModelState));
            }

            var modifyTourViewModel = _mapper.Map <TourDto, ModifyTourViewModel>(result.Value);

            modifyTourViewModel = await _modifyTourViewModelFactory.CreateAsync(modifyTourViewModel);

            return(View("Update", modifyTourViewModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetById(int id)
        {
            if (id == default)
            {
                return(NotFound());
            }

            var query = new GetTourByIdQuery
            {
                Id = id
            };

            var result = await _mediator.Send(query);

            if (result.Failure)
            {
                return(NotFound());
            }

            var viewModel = _mapper.Map <TourDto, TourDetailsViewModel>(result.Value);

            return(View("TourDetails", viewModel));
        }