public Task <bool> Handle(UpdateImageCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); Task.FromResult(false); } var image = new Image(request.ImageId, request.ImageLink, request.ProfileImage, request.Product); var existingImage = _imageRepository.GetById(image.ImageId); if (existingImage != null && existingImage.ImageId == image.ImageId) { if (!existingImage.Equals(image)) { _bus.RaiseEvent(new DomainNotification(request.MessageType, "The image has already been created.")); return(Task.FromResult(false)); } } _imageRepository.Update(image); if (Commit()) { _bus.RaiseEvent(new ImageUpdatedEvent(image.ImageId, image.ImageLink, image.ProfileImage, image.Product)); } return(Task.FromResult(true)); }
public async Task <Result> UpdateImageAsync(UpdateImageCommand command) { var image = await ImageStore.GetImageAsync(command.ImageId); if (image == null) { return(Result.Failed(new Error("Image not found", "Image not found"))); } image.Description = command.Description; image.Name = command.Name; image.Data = command.Data; image.ContentType = command.ContentType; image.FileName = command.FileName; return(await ImageStore.UpdateImageAsync(image, CancellationToken)); }
public ConstInfoModelView() { string mystr = ""; mystr = GetConstInfo(); this.constInfoModel = new ConstInfoModel() { InfoString = mystr, InfoDate = DateTime.Today.Date, MoreInfoe = "", MyImage = GetImageFromDB() }; UpdateImageSource(); this.MyConstSaveCommand = new ConstSaveCommand(this); this.updateImageCommand = new UpdateImageCommand(this); DisplayValue(); }