Exemple #1
0
 public ArticlesController(IGetArticlesCommand searchArticlesCommand, IGetArticleCommand getOneArticleCommand, ICreateArticleCommand createArticleCommand, IEditArticleCommand editArticleCommand, IDeleteArticleCommand deleteArticleCommand)
 {
     _searchArticlesCommand = searchArticlesCommand;
     _getOneArticleCommand  = getOneArticleCommand;
     _createArticleCommand  = createArticleCommand;
     _editArticleCommand    = editArticleCommand;
     _deleteArticleCommand  = deleteArticleCommand;
 }
 public ArticlesController(
     IGetArticlesListQuery listQuery,
     IGetArticleQuery singleQuery,
     ICreateArticleCommand createCommand,
     IUpdateArticleCommand updateCommand,
     IDeleteArticleCommand deleteCommand
     )
 {
     _listQuery     = listQuery;
     _singleQuery   = singleQuery;
     _createCommand = createCommand;
     _updateCommand = updateCommand;
     _deleteCommand = deleteCommand;
 }
Exemple #3
0
        public IActionResult Post([FromForm] CreateArticleDto dto, [FromServices] ICreateArticleCommand command)
        {
            var guid      = Guid.NewGuid();
            var extension = Path.GetExtension(dto.ImageObj.FileName);

            var newFileName = guid + extension;

            var path = Path.Combine("wwwroot", "images", newFileName);

            using (var fileStream = new FileStream(path, FileMode.Create))
            {
                dto.ImageObj.CopyTo(fileStream);
            }
            dto.Picture = newFileName;
            executor.ExecuteCommand(command, dto);
            return(StatusCode(StatusCodes.Status201Created));
        }
 public void Post([FromBody] CreateArticleDto dto, [FromServices] ICreateArticleCommand command)
 {
     executor.ExecuteCommand(command, dto);
 }
Exemple #5
0
 public IActionResult Post([FromBody] ArticlesDto dto, [FromServices] ICreateArticleCommand command)
 {
     _executor.ExecuteCommand(command, dto);
     return(NoContent());
 }
Exemple #6
0
 public CreateArticleCommandBuilder(ICreateArticleCommand cmd)
 {
     _cmd = cmd;
 }