Пример #1
0
        public async Task <IActionResult> Edit([FromForm] EditBlogCommand command)
        {
            command.LoginUserId = ClientUser.UUID;
            var cmdResult = await _mediator.Send(command);

            return(Ok(cmdResult));
        }
Пример #2
0
        public ActionResult Edit(EditBlogViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            EditBlogCommand command = new EditBlogCommand
            {
                Id             = vm.Id,
                Title          = vm.Title,
                PreviewContent = vm.PreviewContent,
                HtmlContent    = vm.HtmlContent,
                IsPublished    = vm.IsPublished
            };

            if (vm.Image != null)
            {
                var result = SaveAs(vm.Image, PlatformConfiguration.UploadedBlogPath);

                if (result.ResultCode == CommandResultCode.Success && result.File != null)
                {
                    command.FileId = result.File.Id;
                }
            }

            Command.Execute(command);

            return(RedirectToAction("Details", new { id = vm.Id }));
        }