コード例 #1
0
 public ArticlesController(
     IGetArticlesListQuery listQuery,
     IGetArticleQuery singleQuery,
     ICreateArticleCommand createCommand,
     IUpdateArticleCommand updateCommand,
     IDeleteArticleCommand deleteCommand
     )
 {
     _listQuery     = listQuery;
     _singleQuery   = singleQuery;
     _createCommand = createCommand;
     _updateCommand = updateCommand;
     _deleteCommand = deleteCommand;
 }
コード例 #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());
        }
コード例 #3
0
 public void Put(int id, [FromBody] ArticlesDto dto, [FromServices] IUpdateArticleCommand command)
 {
     executor.ExecuteCommandUpdate(command, dto, id);
 }
コード例 #4
0
 public IActionResult Put(int id, [FromBody] ArticlesDto dto, [FromServices] IUpdateArticleCommand command)
 {
     _executor.ExecuteCommandUpdate(command, dto, id);
     return(NoContent());
 }
コード例 #5
0
 public UpdateArticleCommandBuilder(IUpdateArticleCommand updateArticleCommand)
 {
     _updateArticleCommand = updateArticleCommand;
 }