public ActionResult Create()
        {
            ProductManagerVM viewModel = new ProductManagerVM();

            viewModel.Product    = new Product();
            viewModel.Categories = ProductCategoris.Collection().ToList();
            return(View(viewModel));
        }
Esempio n. 2
0
        public ActionResult Create()
        {
            ProductManagerVM vm = new ProductManagerVM();

            vm.Product           = new Product();
            vm.ProductCategories = productCategories.Collection();
            return(View(vm));
        }
        public ActionResult Create()
        {
            ProductManagerVM viewModel = new ProductManagerVM();

            viewModel.ProductCategories = productCategoryContext.Collection();
            viewModel.Product           = new Product();
            return(View(viewModel));
        }
        public ActionResult Edit(string Id)
        {
            var productToEdit = productContext.FindProduct(Id);

            if (productToEdit == null)
            {
                return(HttpNotFound());
            }
            ProductManagerVM viewModel = new ProductManagerVM();

            viewModel.Product           = productToEdit;
            viewModel.ProductCategories = productCategoryContext.Collection();
            return(View(viewModel));
        }
Esempio n. 5
0
        public ActionResult Edit(string id)
        {
            Product product = context.Find(id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerVM vm = new ProductManagerVM();
                vm.Product           = product;
                vm.ProductCategories = productCategories.Collection();
                return(View(vm));
            }
        }
Esempio n. 6
0
        private async void DropProduct(IDropInfo dropInfo)
        {
            var parentCategory = (dropInfo.DragInfo.VisualSource as Control)?.DataContext as CategoryVM;

            var targetCategory = dropInfo.TargetItem as CategoryVM;
            var products       = (dropInfo.Data as IEnumerable <ProductVM>)?.ToList();

            if (products is null)
            {
                var product = dropInfo.Data as ProductVM;
                if (product is null)
                {
                    return;
                }
                products = new List <ProductVM> {
                    product
                };
            }

            var dg = dropInfo.DragInfo.VisualSource as DataGrid;

            if (dg.DataContext is MainVM mainVm && mainVm.SearchVM.IsStarted)
            {
                await View.MessageBox.ShowAsync("Добавление складчин в категорию во время поиска недоступно.", "Ошибка",
                                                MessageBoxButton.OK, MessageBoxImage.Information).ConfigureAwait(false);

                return;
            }

            if (dropInfo.KeyStates != DragDropKeyStates.ControlKey)
            {
                if (parentCategory != null)
                {
                    await parentCategory.RemoveProductsAsync(products).ConfigureAwait(false);
                }
                else
                {
                    var itemsSource = dg.ItemsSource as ObservableCollection <ProductVM>;

                    foreach (var productVm in products)
                    {
                        itemsSource.Remove(productVm);
                    }
                }
            }
            await ProductManagerVM.AddProductToCategoryAsync(targetCategory, products).ConfigureAwait(false);
        }