public CarouselImage(TravelListItemImage image) { TravelListItemImageID = image.TravelListItemImageID; TravelListItemID = image.TravelListItemID; ImageData = image.ImageData; ImageName = image.ImageName; }
public async Task DeleteTravelListImage(TravelListItemImage tl) { if (tl == null) { throw new ArgumentNullException(nameof(tl)); } _context.TravelListImages.Remove(tl); await _context.SaveChangesAsync(); }
private async Task CreateImageByName(string name, TravelListItem item) { try { string fileToLaunch = @"Assets\Seeding\" + name + ".jpg"; StorageFile inputFile = await Package.Current.InstalledLocation.GetFileAsync(fileToLaunch); byte[] dataArrayTobeSent = await ConvertImageToByte(inputFile); var newTravelListItemImage = new TravelListItemImage(); newTravelListItemImage.TravelListItemID = item.TravelListItemID; newTravelListItemImage.ImageName = Guid.NewGuid() + inputFile.FileType; newTravelListItemImage.ImageData = dataArrayTobeSent; await CreateTravelListImage(newTravelListItemImage); } catch (FileNotFoundException) { } }
private async void Convert_Click(object sender, RoutedEventArgs e) { FileOpenPicker fileOpenPicker = new FileOpenPicker(); fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; fileOpenPicker.FileTypeFilter.Add(".jpg"); fileOpenPicker.ViewMode = PickerViewMode.Thumbnail; StorageFile inputFile = await fileOpenPicker.PickSingleFileAsync(); if (inputFile == null) { // The user cancelled the picking operation return; } SoftwareBitmap softwareBitmap; using (IRandomAccessStream stream = await inputFile.OpenAsync(FileAccessMode.Read)) { // Create the decoder from the stream BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream); // Get the SoftwareBitmap representation of the file softwareBitmap = await decoder.GetSoftwareBitmapAsync(); } var bitmap = softwareBitmap; var imgSource = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight); bitmap.CopyToBuffer(imgSource.PixelBuffer); byte[] dataArrayTobeSent = await ConvertImageToByte(inputFile); imageName = Guid.NewGuid() + inputFile.FileType; imageData = dataArrayTobeSent; TravelListItemImage liImage = new TravelListItemImage() { ImageData = imageData, ImageName = imageName, }; CarouselImage cImage = await ViewModel.ConvertImageTask(liImage); cImage.IsNew = true; ViewModel.imageChanges.Add(cImage); ViewModel.ImageChangesCheck = new List <CarouselImage>(ViewModel.imageChanges); cImages.Add(cImage); }
public async Task DeleteTravelListImage(TravelListItemImage tl) => await _http.DeleteAsync("travellistimages", tl.TravelListItemImageID);
public async Task CreateTravelListImage(TravelListItemImage tl) => await _http.UploadAsync <TravelListItemImage, TravelListItemImage>("travellistimages", tl.ImageName, tl.TravelListItemID, tl.ImageData);
private async Task CreateTravelListImage(TravelListItemImage travelListItemImage) { await App.Repository.TravelListImages.CreateTravelListImage(travelListItemImage); }