Esempio n. 1
0
 public IActionResult Put(int id,
                          [FromBody] CreateChainDto chainDto,
                          [FromServices] IEditChainCommand editChainCommand)
 {
     chainDto.Id = id;
     _dispatcher.DispatchCommand(editChainCommand, chainDto);
     return(NoContent());
 }
Esempio n. 2
0
        public void Execute(CreateChainDto createChainDto)
        {
            this.createChainValidator.ValidateAndThrow(createChainDto);

            var chain = mapper.Map <Chain>(createChainDto);

            this.context.Chains.Add(chain);
            this.context.SaveChanges();
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
 public IActionResult Post([FromBody] CreateChainDto createChainDto, [FromServices] ICreateChainCommand createChainCommand)
 {
     _dispatcher.DispatchCommand(createChainCommand, createChainDto);
     return(StatusCode(StatusCodes.Status201Created));
 }