private async void AddNewPictureAction(object obj) { ModelsShared.Photo ph = new ModelsShared.Photo(); var dialogresult = ResourcesBase.ShowOpenFileDialog(); string filename = dialogresult.FileName; if (!string.IsNullOrEmpty(filename)) { using (var stream = new MemoryStream()) { var file = File.Open(filename, FileMode.Open); file.CopyTo(stream); file.Close(); ph.Picture = stream.ToArray(); } ph.PenjualanId = PenjualanItem.Id; ph.Ext = filename.Split('.')[1]; var context = ResourcesBase.GetMainWindowViewModel().PenjualanCollection; var res = await context.AddNewPhoto(ph); if (res != null) { Galeries.Add(res); GaleriesView.Refresh(); SelectedPhoto = res; } } }