Exemplo n.º 1
0
        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;
                }
            }
        }
Exemplo n.º 2
0
        private async void GetPictureById(ModelsShared.Photo photo)
        {
            var context = ResourcesBase.GetMainWindowViewModel().PenjualanCollection;

            photo.Picture = await context.GetPictureById(photo.Id);
        }