public async Task <IActionResult> Delete([FromRoute] string key) { try { DeleteImageCommand command = new DeleteImageCommand(key); DeleteImageCommandResult result = await Mediator.Send(command); if (result == null) { return(StatusCode(500)); } if (result.Deleted == null || !result.Deleted.Any()) { return(NotFound()); } else { return(Ok(result)); } } catch (Exception ex) { _logger.LogError(ex, string.Empty); return(StatusCode(500)); } }
void _innerItem_PropertyChanged(object sender, PropertyChangedEventArgs e) { _innerItem.PropertyChanged -= _innerItem_PropertyChanged; DeleteImageCommand.RaiseCanExecuteChanged(); OnPropertyChanged("IsValid"); _innerItem.PropertyChanged += _innerItem_PropertyChanged; }
private void DeleteImage(int imageId) { Image image = Repository.GetImage(imageId, false /* activeOnly */); var command = new DeleteImageCommand(image, Url.ImageGalleryDirectoryUrl(Blog, image.CategoryID)) { ExecuteSuccessMessage = string.Format(CultureInfo.CurrentCulture, "Image '{0}' deleted", image.OriginalFile) }; Messages.ShowMessage(command.Execute()); BindGallery(); }
public void DeleteImage(DeleteImageCommand command) { try { repository.DeleteImage(command.ImageId); } catch (Exception ex) { command.Response = String.Format(EventMessage.ERROR, ex.Message); return; } command.Response = EventMessage.SUCCESS; }
public async Task ShouldDeleteImage() { var image = await AddImage(); IRequestHandler <DeleteImageCommand> handler = new DeleteImageCommandHandler(RequestDbContext, TestContext.CreateImageService()); var message = new DeleteImageCommand() { Id = image.Id }; await handler.Handle(message, CancellationToken.None); Assert.Equal(null, await RequestDbContext.Images.FindAsync(image.Id)); }
/// <summary> /// 删除与笔迹strokes相交的图像 /// </summary> /// <param name="strokes"></param> public void removeHitImages(StrokeCollection strokes) { List <MyImage> myImages = new List <MyImage>(); foreach (MyImage myImage in Sketch.Images) { Rect rectMyImage = new Rect(new Point(myImage.Left, myImage.Top), new Point(myImage.Left + myImage.Width, myImage.Top + myImage.Height)); if (MathTool.getInstance().isHitRects(strokes.GetBounds(), rectMyImage) == true) { myImages.Add(myImage); } } foreach (MyImage myImage in myImages) { Command dbc = new DeleteImageCommand(this, myImage); dbc.execute(); CommandStack.Push(dbc); } }
public IActionResult Delete(ImageDelete model) { DeleteImageCommand command = new DeleteImageCommand(); try { command.ImageId = model.ImageId; service.DeleteImage(command); if (command.Response != EditImageCommand.SUCCESS) { throw new ArgumentException(EditImageCommand.ERROR, "Business Logic Error"); } } catch (Exception ex) { throw ex; } return(RedirectToAction("Index", new { message = "Image deleted" })); }
public async Task <ActionResult <DeleteImageCommandResponse> > Delete([FromRoute] DeleteImageCommand request) { return(await Send(request)); }
public async Task <IActionResult> DeleteImage([FromBody] DeleteImageCommand image) { return(Ok(await Mediator.Send(image))); }
public Task <Result> DeleteImageAsync(DeleteImageCommand command) { return(ImageStore.DeleteImageAsync(command.ImageId, CancellationToken)); }
public async Task <ActionResult <DeleteImageCommandResponse> > Delete(DeleteImageCommand request, CancellationToken cancellationToken = default(CancellationToken)) { return(await Mediator.Send(request, cancellationToken)); }