コード例 #1
0
        public async Task <IActionResult> Post([FromBody] MarkViewModel viewModel)
        {
            if (!ModelState.IsValid || viewModel.MarkDate > DateTime.Now)
            {
                return(BadRequest(ModelState));
            }

            viewModel.Id = await _markService.CreateAsync(viewModel.ToDto(), Bll.Extensions.MarkExtensions.ToEntity);

            return(CreatedAtAction(nameof(Get), viewModel));
        }
コード例 #2
0
        public async Task <IActionResult> Put(int id, [FromBody] MarkViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            viewModel.Id = id;
            await _markService.UpdateAsync(viewModel.ToDto(), Bll.Extensions.MarkExtensions.ToEntity);

            return(NoContent());
        }