public ActionResult Create([Bind(Include = "CategoryID,CategoryName,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "CustomerID,Firstname,Lastname,MailAdress,StreetAdress,City,ZipCode,CompanyName,CompanyPhoneNumber,CompanyWebSite")] CorporateCustomer corporateCustomer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(corporateCustomer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(corporateCustomer));
        }
        public ActionResult Create([Bind(Include = "ShippingCompanyID,ShippingCompanyName,ShippingCost")] ShippingCompany shippingCompany)
        {
            if (ModelState.IsValid)
            {
                db.ShippingCompanies.Add(shippingCompany);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(shippingCompany));
        }
예제 #4
0
        public ActionResult Create([Bind(Include = "CustomerID,Firstname,Lastname,MailAdress,StreetAdress,City,ZipCode,MobileNumber")] PrivateCustomer privateCustomer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(privateCustomer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(privateCustomer));
        }
예제 #5
0
        public ActionResult Create([Bind(Include = "ManufacturerID,ManufacturerName")] Manufacturer manufacturer)
        {
            if (ModelState.IsValid)
            {
                db.Manufacturers.Add(manufacturer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(manufacturer));
        }
        public ActionResult Create([Bind(Include = "OrderID,ProductID,ProductQuantity")] ProductOrder productOrder)
        {
            if (ModelState.IsValid)
            {
                db.ProductOrders.Add(productOrder);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OrderID   = new SelectList(db.Orders, "OrderID", "OrderID", productOrder.OrderID);//changed second parameter from orderstatus to orderid
            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductName", productOrder.ProductID);
            return(View(productOrder));
        }
예제 #7
0
        public ActionResult Create([Bind(Include = "OrderID,ShippingDate,CustomerID,ShippingCompanyID")] Order order)   //removed orderstatus and totalprice from the bind include
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerID        = new SelectList(db.Customers, "CustomerID", "Firstname", order.CustomerID);
            ViewBag.ShippingCompanyID = new SelectList(db.ShippingCompanies, "ShippingCompanyID", "ShippingCompanyName", order.ShippingCompanyID);
            return(View(order));
        }
예제 #8
0
        public ActionResult Create([Bind(Include = "ProductID,DiscountPercentage,Stock,UnitPrice,ProductName,CategoryID,ManufacturerID")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryID     = new SelectList(db.Categories, "CategoryID", "CategoryName", product.CategoryID);
            ViewBag.ManufacturerID = new SelectList(db.Manufacturers, "ManufacturerID", "ManufacturerName", product.ManufacturerID);
            return(View(product));
        }
예제 #9
0
        public IActionResult Confirmed(AccountMyProfileEditVM account)
        {
            MyShoppingCartVM myCartVM;

            if (User.Identity.IsAuthenticated)
            {
                string userID     = signInManager.UserManager.GetUserId(HttpContext.User);
                int    customerID = webShopDBContext.User.First(u => u.Uid == userID).Id;
                myCartVM = SessionUtils.GetArticles(this, webShopDBContext);
                webShopDBContext.AddOrder(customerID, myCartVM, webShopDBContext);
            }
            else
            {
                webShopDBContext.User.Add(new User {
                    Firstname   = account.FirstName,
                    Lastname    = account.LastName,
                    Phonenumber = account.PhoneNumber,
                    Email       = account.Email,
                    Addressline = account.AddressLine,
                    Zipcode     = account.ZipCode,
                    City        = account.City
                });
                webShopDBContext.SaveChanges();

                int customerID = webShopDBContext.User.First(u => u.Email == account.Email).Id;
                myCartVM = SessionUtils.GetArticles(this, webShopDBContext);
                webShopDBContext.AddOrder(customerID, myCartVM, webShopDBContext);
            }
            HttpContext.Session.Clear();

            return(View());
        }
예제 #10
0
 public Shoe CreateShoe(Shoe shoeToCreate)
 {
     _context.Shoes.Attach(shoeToCreate).State = EntityState.Added;
     _context.SaveChanges();
     return(shoeToCreate);
 }