public void Execute(ShoeTypeDto request) { request.Id = 0; _validator.ValidateAndThrow(request); _context.ShoeTypes.Add(_maper.Map <ShoeType>(request)); _context.SaveChanges(); }
public void Execute(ShoeTypeDto request) { _validator.ValidateAndThrow(request); var shoeType = _context.ShoeTypes.Find(request.Id); if (shoeType == null) { throw new EntityNotFoundException(request.Id, typeof(ShoeType)); } _maper.Map(request, shoeType); _context.SaveChanges(); }
public IActionResult Put(int id, [FromBody] ShoeTypeDto dto, [FromServices] IShoeTypeUpdateCommand command) { dto.Id = id; executor.ExecuteCommand(command, dto); return(NoContent()); }
public IActionResult Post([FromBody] ShoeTypeDto dto, [FromServices] IShoeTypeAddCommand command) { executor.ExecuteCommand(command, dto); return(StatusCode(StatusCodes.Status201Created)); }