Пример #1
0
        public async Task <IActionResult> Create([FromBody] AccommodationViewModel viewModel)
        {
            var model        = Mapper.Map <Accommodation>(viewModel);
            var createdModel = await _accommodationService.AddAsync(model);

            var createdViewModel = Mapper.Map <AccommodationViewModel>(createdModel);

            return(CreatedAtRoute(
                       nameof(AccommodationController.GetById),
                       new { id = createdViewModel.Id },
                       createdViewModel));
        }
Пример #2
0
 //[Authorize(Roles = "Accommodation-AddAccommodation")]
 public async Task <IActionResult> AddAccommodation([FromBody] AddAccommodationFormModel accommodationForm)
 {
     return(Ok(GetRequestResult(await _accommodationService.AddAsync(accommodationForm))));
 }