public ArticlesController(
     IGetArticlesListQuery listQuery,
     IGetArticleQuery singleQuery,
     ICreateArticleCommand createCommand,
     IUpdateArticleCommand updateCommand,
     IDeleteArticleCommand deleteCommand
     )
 {
     _listQuery     = listQuery;
     _singleQuery   = singleQuery;
     _createCommand = createCommand;
     _updateCommand = updateCommand;
     _deleteCommand = deleteCommand;
 }
Esempio n. 2
0
        public IActionResult Put(int id, [FromForm] UpdateArticleDto dto, [FromServices] IUpdateArticleCommand command)
        {
            if (dto.ImageObj != null)
            {
                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;
            }

            dto.Id = id;
            executor.ExecuteCommand(command, dto);
            return(NoContent());
        }
Esempio n. 3
0
 public void Put(int id, [FromBody] ArticlesDto dto, [FromServices] IUpdateArticleCommand command)
 {
     executor.ExecuteCommandUpdate(command, dto, id);
 }
Esempio n. 4
0
 public IActionResult Put(int id, [FromBody] ArticlesDto dto, [FromServices] IUpdateArticleCommand command)
 {
     _executor.ExecuteCommandUpdate(command, dto, id);
     return(NoContent());
 }
 public UpdateArticleCommandBuilder(IUpdateArticleCommand updateArticleCommand)
 {
     _updateArticleCommand = updateArticleCommand;
 }