예제 #1
0
        public void LoadImages(string fabCode)
        {
            ImageCollection = new ObservableCollection <GImageViewModel>();
            g_IsBusy        = true;
            var client = new _Proxy.CRUD_ManagerServiceClient();

            client.GetFabricImagesByFabricCompleted += (s, e) =>
            {
                if (e.Error == null)
                {
                    foreach (var item in e.Result)
                    {
                        ImageCollection
                        .Add(FabricSetupsViewModelMapper
                             .MapToViewModelObject(item, fabCode));
                    }
                    g_IsBusy = false;
                }
                RaisePropertyChanged("ImageCollection");
                g_IsBusy = false;
            };
            client.GetFabricImagesByFabricAsync(fabCode);
        }
예제 #2
0
        public void SaveImages()
        {
            if (ImageCollection.Count > 0)
            {
                g_IsBusy = true;
                var newImages     = new ObservableCollection <_Proxy.tbl_FabricImage>();
                var updatedImages = new ObservableCollection <_Proxy.tbl_FabricImage>();

                foreach (var item in ImageCollection)
                {
                    if (item._ImageState == ImageCondition.NewAdded)
                    {
                        newImages.Add(FabricSetupsViewModelMapper.MapToModelObject(item));
                    }
                    else if (item._ImageState == ImageCondition.LoadedAndChanged)
                    {
                        updatedImages.Add(FabricSetupsViewModelMapper.MapToModelObject(item));
                    }
                }
                var client = new _Proxy.CRUD_ManagerServiceClient();
                if (newImages.Count > 0)
                {
                    client.AddFabricGalaryCompleted += (s, e) =>
                    {
                        if (e.Error != null)
                        {
                            g_IsBusy = false;
                            throw new Exception("Error!, Data was not added\n" + e.Error.Message);
                        }
                        else
                        {
                            MessageBox.Show("Data was added successfully");
                            g_IsBusy = false;
                        }
                        g_IsBusy = false;
                    };
                    client.AddFabricGalaryAsync(newImages);
                }
                if (updatedImages.Count > 0)
                {
                    client.UpdateFabricGalaryCompleted += (s, e) =>
                    {
                        if (e.Error != null)
                        {
                            g_IsBusy = false;
                            throw new Exception("Error!, Data was not Updated\n" + e.Error.Message);
                        }
                        else
                        {
                            MessageBox.Show("Data was updated successfully");
                            g_IsBusy = false;
                        }
                        g_IsBusy = false;
                    };
                    client.UpdateFabricGalaryAsync(updatedImages);
                }
            }
            else
            {
                MessageBox.Show("data are not valid for saving!");
            }
        }