Пример #1
0
        public async Task <IActionResult> Post([FromBody] DetailViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            viewModel.Id = await _detailService.CreateAsync(viewModel.ToDto(), Bll.Extensions.DetailExtensions.ToEntity);

            return(CreatedAtAction(nameof(Get), viewModel));
        }
Пример #2
0
        public async Task <IActionResult> Put(int id, [FromBody] DetailViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            viewModel.Id = id;
            await _detailService.UpdateAsync(viewModel.ToDto(), Bll.Extensions.DetailExtensions.ToEntity);

            return(NoContent());
        }