public IActionResult Put(int id, [FromBody] CreateChainDto chainDto, [FromServices] IEditChainCommand editChainCommand) { chainDto.Id = id; _dispatcher.DispatchCommand(editChainCommand, chainDto); return(NoContent()); }
public void Execute(CreateChainDto createChainDto) { this.createChainValidator.ValidateAndThrow(createChainDto); var chain = mapper.Map <Chain>(createChainDto); this.context.Chains.Add(chain); this.context.SaveChanges(); }
public void Execute(CreateChainDto chainDto) { this.chainValidation.ValidateAndThrow(chainDto); var chain = this.context.Chains .FirstOrDefault(c => c.Id == chainDto.Id); if (chain == null) { throw new EntityNotFoundException(chainDto.Id); } this.mapper.Map(chainDto, chain); this.context.SaveChanges(); }
public IActionResult Post([FromBody] CreateChainDto createChainDto, [FromServices] ICreateChainCommand createChainCommand) { _dispatcher.DispatchCommand(createChainCommand, createChainDto); return(StatusCode(StatusCodes.Status201Created)); }