public ActionResult <CommandReadDto> CreateCommand(CommandCreateDto commandCreateDto) { //Source var commandModel = _mapper.Map <Command>(commandCreateDto); _repository.CreateCommand(commandModel); _repository.SaveChanges(); var commandReadDto = _mapper.Map <CommandReadDto>(commandModel); return(CreatedAtRoute(nameof(GetCommandById), new { Id = commandReadDto.Id }, commandReadDto)); // return Ok(commandReadDto); }
//public Task<ActionResult<WebApiReadDto>> CreateCommand(WebApiCreateDto webApiCreateDto) //{ // var commandModel = _mapper.Map<WebApiModel>(webApiCreateDto); // _repository.CreateCommand(commandModel); // _repository.SaveChanges(); // var commandReadDto = _mapper.Map<WebApiReadDto>(commandModel); // return CreatedAtRoute(nameof(GetCommandById), new { ID = commandReadDto.Id }, commandReadDto); //} public ActionResult <WebApiReadDto> CreateCommand(WebApiCreateDto commandCreateDto) { var commandModel = _mapper.Map <WebApiModel>(commandCreateDto); _repository.CreateCommand(commandModel); _repository.SaveChanges(); var commandReadDto = _mapper.Map <WebApiReadDto>(commandModel); return(CreatedAtRoute(nameof(GetCommandById), new { ID = commandReadDto.id }, commandReadDto)); //return Ok(commandReadDto); }