public async Task <IActionResult> Create(TargetCreateViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var targetDto = _mapper.Map <TargetDto>(model); targetDto.UserId = UserId; var serviceResult = await _targetService.AddAsync(targetDto); if (!serviceResult.Success) { AddModelErrors(serviceResult); return(View(model)); } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> AddTarget(TargetAddDto targetAddDto) { await _targetService.AddAsync(_mapper.Map <Target>(targetAddDto)); return(Created("", targetAddDto)); }