Exemplo n.º 1
0
        public IActionResult Edit(string id)
        {
            var productToEdit = _productRepository.Find(id);

            if (productToEdit == null)
            {
                return(NotFound());
            }

            var viewModel = new ProductManagerViewModel
            {
                Product           = productToEdit,
                ProductCategories = _productCategoryRepository.Collection()
            };

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public ActionResult Edit(String id)
        {
            Product product = Context.Find(id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel pmViewModel = new ProductManagerViewModel();

                pmViewModel.Product           = product;
                pmViewModel.ProductCategories = productCategories.Collection();
                return(View(pmViewModel));
            }
        }
Exemplo n.º 3
0
        public ActionResult Edit(String Id)
        {
            Product productToUpdate = context.Find(Id);

            if (null == productToUpdate)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel viewModel = new ProductManagerViewModel();
                viewModel.Product           = productToUpdate;
                viewModel.ProductCategories = productCategories.Collection();

                return(View(viewModel));
            }
        }
Exemplo n.º 4
0
        public ActionResult Edit(string Id)
        {
            Product product = context.Find(Id);

            if (product == null)
            {
                return(HttpNotFound());
            }

            ProductManagerViewModel viewModel = new ProductManagerViewModel();

            // this isn third class which store Product and ProductCategory
            viewModel.Product           = product;
            viewModel.ProductCategories = productCategories.Collection();

            return(View(viewModel));
        }
Exemplo n.º 5
0
        public ActionResult Edit(String Id)            //shows Initial Edit page to edit
        {
            Products productToEdit = context.Find(Id); //finds the product based on id in the list

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

                viewModel.product           = productToEdit;                  //puting product info in viewModel
                viewModel.ProductCategories = productCategories.Collection(); //Loading collection of category from collection
                return(View(viewModel));                                      //passing viewModel onto the edit page
            }
        }
        public ActionResult Edit(string Id)     // displays product for editing
        {
            Product product = context.Find(Id); // find it from the database

            if (product == null)
            {
                return(HttpNotFound()); // if not found - error
            }
            else
            {
                ProductManagerViewModel viewModel = new ProductManagerViewModel();
                viewModel.Product           = product;
                viewModel.ProductCategories = productCategories.Collection(); // list of categories that will be viewed via dropdown

                return(View(viewModel));                                      // if found, return it to the View
            }
        }
Exemplo n.º 7
0
        public ActionResult Edit(string Id)
        {
            Product product = context.Find(Id);//Tries to find the product using the find method and by Id

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel viewModel = new ProductManagerViewModel();//Getting either an empty product or a product from the DB
                viewModel.Product           = product;
                viewModel.ProductCategories = productCategories.Collection();

                return(View(viewModel));
            }
        }
Exemplo n.º 8
0
        public ActionResult Edit(string id)
        {
            var product = productRepo.Find(id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel productManagerViewModel = new ProductManagerViewModel();
                productManagerViewModel.Product           = product;
                productManagerViewModel.ProductCategories = productCategoryRepo.Collection();

                return(View(productManagerViewModel));
            }
        }
Exemplo n.º 9
0
        public ActionResult Edit(String Id)
        {
            Carpenter carpenter = context.Find(Id);

            if (carpenter == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel viewModel = new ProductManagerViewModel();
                viewModel.Carpenter         = carpenter;
                viewModel.ProductCategories = productCategories.Collection();

                return(View(viewModel));
            }
        }
Exemplo n.º 10
0
        public ActionResult Edit(string Id)
        {
            Product product = context.Find(Id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel viewModel = new ProductManagerViewModel();
                viewModel.Product           = product;
                viewModel.ProductCatagories = productCatagories.Collection();

                return(View(viewModel));
            }
        }
Exemplo n.º 11
0
        public ActionResult Create(ProductManagerViewModel p, HttpPostedFileBase image)
        {
            if (!ModelState.IsValid)
            {
                return(View(p));
            }

            if (image != null && image.ContentLength > 0)
            {
                p.Product.Image = p.Product.ID + Path.GetExtension(image.FileName);
                image.SaveAs(Server.MapPath("//Content//product_images//") + p.Product.Image);
            }

            this.productsCtx.Save(p.Product);
            this.productsCtx.Commit();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 12
0
        public ActionResult Edit(string Id)
        {
            // Fint product by ID
            var product = context.Find(Id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel productManagerViewModel = new ProductManagerViewModel();
                productManagerViewModel.product           = product;
                productManagerViewModel.productCategories = productCategory.Collection();
                return(View(productManagerViewModel));
            }
        }
        public ActionResult Edit(String Id)
        {
            /* 'aca estamos asignando ID ingresado de persona a productos, despues estamos validando
             * si existe o no' */
            Product product = context.Find(Id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel viewModel = new ProductManagerViewModel();
                viewModel.Product           = product;
                viewModel.ProductCategories = productCategories.Collection();
                return(View(viewModel));
            }
        }
Exemplo n.º 14
0
        // Create the add page
        // this first part calls the create page with an empty form
        public ActionResult Create()
        {
            // with a view model this becomes
            // first we need to initalise the view model
            ProductManagerViewModel viewModel = new ProductManagerViewModel();

            // then we need to create the empty product from the view model
            viewModel.Product = new Product();
            // then because the view model also includes a property of product categories we can call it
            viewModel.productCategories = productCategories.Collection();

            // now we return the view model not the product model
            return(View(viewModel));

            // This is without the view model
            //Product product = new Product();
            //return View(product);
        }
Exemplo n.º 15
0
        public ActionResult Create(ProductManagerViewModel vm, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            if (file != null)
            {
                vm.Product.Image = vm.Product.Id + Path.GetExtension(file.FileName);
                file.SaveAs(Server.MapPath("//Content//ProductImges//") + vm.Product.Image);
            }

            context.Insert(vm.Product);
            context.Commit();

            return(RedirectToAction("Index"));
        }
        // GET: ProductManager/Edit/5
        public ActionResult Edit(string id)

        {
            Products item = contex.find(id);

            if (item == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel viewModel = new ProductManagerViewModel();
                viewModel.product  = item;
                viewModel.category = productCategories.Collection();

                return(View(viewModel));
            }
        }
Exemplo n.º 17
0
        public ActionResult Edit(string Id)
        {
            Product product = productContext.Find(Id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel productManagerViewModel = new ProductManagerViewModel()
                {
                    Product           = product,
                    ProductCategories = productCategoryContext.Collection()
                };
                return(View(productManagerViewModel));
            }
        }
        public ActionResult Edit(string Id)
        {
            Product product = context.Find(Id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel viewModel = new ProductManagerViewModel();
                // NOTE 1: ".. = new Product();" was wrong..we want the existing: product
                // NOTE 2: beware of this bug when using older git commits.. ref. NOTE 1
                viewModel.Product           = product;
                viewModel.ProductCategories = productCategories.Collection();
                return(View(viewModel));
            }
        }
Exemplo n.º 19
0
        public ActionResult Edit(string id)
        {
            Product product = context.Find(id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            {
                ProductManagerViewModel viewModel = new ProductManagerViewModel
                {
                    Product           = product,
                    ProductCategories = productCategory.Collection()
                };

                return(View(viewModel));
            }
        }
Exemplo n.º 20
0
        public ActionResult Edit(string Id)
        {
            //Thsi will try to load the product from the database so we use the .find method
            Product product = context.Find(Id);

            if (product == null)
            {
                //if it's not found, we return an http error
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel viewModel = new ProductManagerViewModel();
                viewModel.Product           = product;
                viewModel.ProductCategories = productCategories.Collection();
                //else We return the product with the view we have found
                return(View(viewModel));
            }
        }
Exemplo n.º 21
0
        public ActionResult EditProduct(string id)
        {
            var product = _productContext.Find(id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var viewModel = new ProductManagerViewModel
                {
                    Product           = product,
                    ProductCategories = _productCategoryContext.Collection()
                };

                return(View(viewModel));
            }
        }
Exemplo n.º 22
0
        public ActionResult Edit(string Id)
        {
            Product product = context.Find(Id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                //geting a empty product, or product we have loaded from database.
                //Using viewModel to hold that Product and the list of Categories
                ProductManagerViewModel viewModel = new ProductManagerViewModel();
                viewModel.Product           = product;
                viewModel.ProductCategories = productCategories.Collection();

                return(View(viewModel));
            }
        }
Exemplo n.º 23
0
        //edit product
        public ActionResult Edit(string Id)//to find the product
        {
            //find the product
            Product product = context.Find(Id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel ViewModel = new ProductManagerViewModel();
                ViewModel.Product = product;
                //get from the database
                ViewModel.ProductCategories = productCategories.Collection();

                return(View(ViewModel));
            }
        }
Exemplo n.º 24
0
        public ActionResult AddNewProduct(ProductManagerViewModel newProdMod)
        {
            try
            {
                using (var db = new BePreferencesEntities())
                {
                    InkeyProduct newProd = newProdMod.NewProduct;

                    db.InkeyProducts.Add(newProd);
                    db.SaveChanges();

                    return(RedirectToAction("ProductManager"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult Create(Product product, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new ProductManagerViewModel {
                    Product = product
                };
                return(View(viewModel));
            }

            if (file != null)
            {
                product.Image = product.Id + Path.GetExtension(file.FileName);
                file.SaveAs(Server.MapPath("/Content/ProductImages/") + product.Image);
            }

            Context.Insert(product);
            Context.Commit();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 26
0
 private void ProductManagerContentFrame_Navigated(object sender, NavigationEventArgs e)
 {
     foreach (UIElement child in ProductManagerMenu.Children)
     {
         HyperlinkButton hb = child as HyperlinkButton;
         if (hb != null && hb.NavigateUri != null)
         {
             if (ProductManagerContentFrame.UriMapper.MapUri(e.Uri).ToString().Equals(ProductManagerContentFrame.UriMapper.MapUri(hb.NavigateUri).ToString()))
             {
                 VisualStateManager.GoToState(hb, "ActiveLink", true);
                 ProductManagerViewModel productManagerViewModel = this.DataContext as ProductManagerViewModel;
                 productManagerViewModel.CurrentPageName = hb.Content.ToString();
             }
             else
             {
                 VisualStateManager.GoToState(hb, "InactiveLink", true);
             }
         }
     }
 }
        public ActionResult AddToCart(string Id)
        {
            ViewBag.IsIndexHome = false;
            Product product = context.Find(Id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ProductManagerViewModel viewModel = new ProductManagerViewModel
                {
                    Product           = product,
                    ProductCategories = productCategories.Collection()
                };

                return(View(viewModel));
            }
        }
Exemplo n.º 28
0
        public ActionResult Edit(string Id)
        {
            var product = context.Find(Id);

            if (product != null)
            {
                //Create an instance of product viewmodel
                var productViewModel = new ProductManagerViewModel();
                //Add an instance of product
                productViewModel.Product = product;
                //Populate categories field
                productViewModel.ProductCategories = productCategories.Collection();

                return(View(productViewModel));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Exemplo n.º 29
0
        public IActionResult ProductManager(int catalogSelect, string keySearch, int page = 1, int pageSize = 5)
        {
            var Catalogs = new ComboBoxController().GetCatalogs(MODE_MANAGER);

            //
            if (string.IsNullOrWhiteSpace(keySearch))
            {
                keySearch = " ";
            }

            List <Product> products = new List <Product>();

            products = productService.SearchFullText(keySearch, catalogSelect, 1);

            //
            List <ProductBasicViewModel> listProduct = new List <ProductBasicViewModel>();

            foreach (var p in products)
            {
                string userName = string.Empty;
                User   user     = userService.Get(p.CreateByUser);
                if (user != null)
                {
                    userName = user.HoTen;
                }

                ProductBasicViewModel product = new ProductBasicViewModel()
                {
                    Id       = p.Id,
                    Name     = p.Name,
                    UserName = userName,
                    State    = p.State
                };
                listProduct.Add(product);
            }
            //
            ProductManagerViewModel model =
                new ProductManagerViewModel(listProduct, page, pageSize, Catalogs, keySearch, catalogSelect);

            return(View(model));
        }
        public ActionResult Edit(string id, ProductManagerViewModel collection, HttpPostedFileBase filer)
        {
            try
            {
                // TODO: Add update logic here

                Products item = contex.find(id);
                if (item == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    if (!ModelState.IsValid)
                    {
                        return(View(collection));
                    }

                    if (filer != null)
                    {
                        collection.product.Image = collection.product.Id + Path.GetExtension(filer.FileName);

                        filer.SaveAs(Server.MapPath("/Content/ProductImages/") + collection.product.Image);
                    }



                    ProductManagerViewModel viewMOdel = new ProductManagerViewModel();
                    viewMOdel.product  = collection.product;
                    viewMOdel.category = productCategories.Collection();


                    contex.Update(collection.product);
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }