public ActionResult <TargetCreateDto> CreateTarget(TargetCreateDto targetCreateDto) { var target = _mapper.Map <Target>(targetCreateDto); target.TargetStatusId = (int)TargetStatuses.NotFound; target.LostTime = targetCreateDto.LostTime.ToLocalTime(); target.OperationId = _operationRepository.GetActiveOperationId(UserId); _targetRepository.Create(target); _targetRepository.SaveChanges(); _notificationHub.Clients.All.SendAsync("SendMessage", "TargetCreated"); _notificationHub.Clients.All.SendAsync("Notification", "Цель " + target.Title + " обновлена."); var targetReadDto = _mapper.Map <Target>(target); return(CreatedAtRoute(nameof(GetTargetById), new { Id = targetReadDto.Id }, targetReadDto)); //Return 201 }
public Target Create(Target item) { Repo.Create(item); Unit.SaveChanges(); return(item); }