Esempio n. 1
0
        public ActionResult Create([Bind(Include = "Id,CompanyName,ContactName,ContactTitle,Address,City,Region,PostalCode,Country,Phone,Fax")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "Id,CompanyName,ContactName,ContactTitle,MyProperty,City,Region,PostalCode,Country,Phone,Fax,HomePage")] Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                db.Suppliers.Add(supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(supplier));
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "Id,Name,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "Id,CompanyName,Phone")] Shipper shipper)
        {
            if (ModelState.IsValid)
            {
                db.Shippers.Add(shipper);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(shipper));
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "Id,CustomerId,OrderDate,RequiredDate,ShippedDate,ShipVia,Freight,ShipName,ShipAddress,ShipCity,ShipRegion,ShipPostalCode,ShipCountry")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerId = new SelectList(db.Customers, "Id", "CompanyName", order.CustomerId);
            return(View(order));
        }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "Id,OrderId,ProductId,UnitPrice,Quantity,Discount")] OrderDetail orderDetail)
        {
            if (ModelState.IsValid)
            {
                db.OrderDetails.Add(orderDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OrderId   = new SelectList(db.Orders, "Id", "ShipName", orderDetail.OrderId);
            ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", orderDetail.ProductId);
            return(View(orderDetail));
        }
Esempio n. 7
0
        public ActionResult Create([Bind(Include = "Id,SectionId,SizeId")] SectionSize sectionSize)
        {
            if (ModelState.IsValid)
            {
                db.SectionSizes.Add(sectionSize);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SectionId = new SelectList(db.Sections, "Id", "Name", sectionSize.SectionId);
            ViewBag.SizeId    = new SelectList(db.Sizes, "Id", "Name", sectionSize.SizeId);
            return(View(sectionSize));
        }
Esempio n. 8
0
        public ActionResult Create([Bind(Include = "Id,Name,SupplierId,CategoryId,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", product.CategoryId);
            ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "CompanyName", product.SupplierId);
            return(View(product));
        }
Esempio n. 9
0
        public ActionResult DeleteConfirmed(int id)
        {
            SectionCategory sectionC = db.SectionCategories.Find(id);

            db.SectionCategories.Remove(sectionC);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 10
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProductColorSize productDb = db.ProductColorSize.Find(id);

            db.ProductColorSize.Remove(productDb);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 11
0
        public ActionResult DeleteConfirmed(int id)
        {
            Image productDb = db.Images.Find(id);

            RemoveImage(productDb.ImageSource, "~/Assets/img");
            db.Images.Remove(productDb);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 12
0
        public ActionResult AddFavorite(int id)
        {
            var product = db.Products.Find(id);

            if (product == null)
            {
                return(Json(new { status = "404" }, JsonRequestBehavior.AllowGet));
            }
            var user = Session["user"] as User;

            db.Favorites.Add(new Favorite()
            {
                ProductId = product.Id,
                UserId    = user.Id
            });
            db.SaveChanges();
            return(Json(new { status = "200" }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 13
0
        public ActionResult DeleteCategory(int?Id)
        {
            if (Id == null)
            {
                return(HttpNotFound("Id is not found"));
            }

            var sizeDb = db.Sizes.Find(Id);

            if (sizeDb == null)
            {
                return(HttpNotFound("Size is not found"));
            }

            db.Sizes.Remove(sizeDb);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 14
0
        public ActionResult DeleteCategory(int?Id)
        {
            if (Id == null)
            {
                return(HttpNotFound("Id is not found"));
            }

            var categoryDb = db.Categories.Find(Id);

            if (categoryDb == null)
            {
                return(HttpNotFound("Customer is not found"));
            }

            db.Categories.Remove(categoryDb);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }