Beispiel #1
0
        // GET: Products/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Product product = db.Products.Find(id);

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

            ViewBag.CategoryId = new SelectList(ComboHelper.GetCategories(product.CompanyId), "CategoryId", "Description", product.CategoryId);
            ViewBag.TaxId      = new SelectList(ComboHelper.GetTaxes(product.CompanyId), "TaxId", "Description", product.TaxId);
            return(View(product));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "ProductId,CompanyId,Description,BarCode,TaxId,CategoryId,Price,Image,Remarks")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            var user = db.Users.Where(u => u.Email == User.Identity.Name).FirstOrDefault();

            if (user == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.CategoryId = new SelectList(ComboHelper.GetCategories(user.CompanyId), "CategoryId", "Description", product.CategoryId);
            ViewBag.TaxId      = new SelectList(ComboHelper.GetTaxes(user.CompanyId), "TaxId", "Description", product.TaxId);
            return(View(product));
        }