public void AddToCart(string shoppingCartID, int productID, int quantity)
        {
            ShoppingCartItem myItem =
                (from c in _db.ShoppingCartItems
                 where c.ShoppingCartID == shoppingCartID && c.ProductID == productID
                 select c).FirstOrDefault();

            if (myItem == null)
            {
                var cartadd = new ShoppingCartItem
                {
                    ShoppingCartID = shoppingCartID,
                    Quantity       = quantity,
                    ProductID      = productID,
                    DateCreated    = DateTime.Now,
                    ModifiedDate   = DateTime.Now
                };
                _db.ShoppingCartItems.AddObject(cartadd);
            }
            else
            {
                myItem.Quantity += quantity;
            }

            _db.SaveChanges();
        }
        public ActionResult Create([Bind(Include = "CountryRegionCode,Name,ModifiedDate,isDeleted")] CountryRegion countryRegion)
        {
            if (ModelState.IsValid)
            {
                db.CountryRegions.Add(countryRegion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(countryRegion));
        }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "ProductCategoryID,Name,rowguid,ModifiedDate,isDeleted")] ProductCategory productCategory)
        {
            if (ModelState.IsValid)
            {
                db.ProductCategories.Add(productCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productCategory));
        }
        public ActionResult Create([Bind(Include = "LocationID,Name,CostRate,Availability,ModifiedDate,isDeleted")] Location location)
        {
            if (ModelState.IsValid)
            {
                db.Locations.Add(location);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(location));
        }
        public ActionResult Create([Bind(Include = "DepartmentID,Name,GroupName,ModifiedDate")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
Beispiel #6
0
        public ActionResult Create([Bind(Include = "ProductDescriptionID,Description,rowguid,ModifiedDate,isDeleted")] ProductDescription productDescription)
        {
            if (ModelState.IsValid)
            {
                db.ProductDescriptions.Add(productDescription);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productDescription));
        }
        public ActionResult Create([Bind(Include = "StateProvinceID,StateProvinceCode,CountryRegionCode,IsOnlyStateProvinceFlag,Name,TerritoryID,rowguid,ModifiedDate,isDeleted")] StateProvince stateProvince)
        {
            if (ModelState.IsValid)
            {
                db.StateProvinces.Add(stateProvince);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(stateProvince));
        }
Beispiel #8
0
        public ActionResult Create([Bind(Include = "CreditCardID,CardType,CardNumber,ExpMonth,ExpYear,ModifiedDate,isDeleted")] CreditCard creditCard)
        {
            if (ModelState.IsValid)
            {
                db.CreditCards.Add(creditCard);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(creditCard));
        }
        public ActionResult Create([Bind(Include = "CultureID,Name,ModifiedDate,isDeleted")] Culture culture)
        {
            if (ModelState.IsValid)
            {
                db.Cultures.Add(culture);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(culture));
        }
Beispiel #10
0
        public ActionResult Create([Bind(Include = "AddressTypeID,Name,rowguid,ModifiedDate,isDeleted")] AddressType addressType)
        {
            if (ModelState.IsValid)
            {
                db.AddressTypes.Add(addressType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(addressType));
        }
Beispiel #11
0
        public ActionResult Create([Bind(Include = "ProductSubcategoryID,ProductCategoryID,Name,rowguid,ModifiedDate,isDeleted")] ProductSubcategory productSubcategory)
        {
            if (ModelState.IsValid)
            {
                db.ProductSubcategories.Add(productSubcategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductCategoryID = new SelectList(db.ProductCategories, "ProductCategoryID", "Name", productSubcategory.ProductCategoryID);
            return(View(productSubcategory));
        }
        public ActionResult Create([Bind(Include = "AddressID,AddressLine1,AddressLine2,City,StateProvinceID,PostalCode,SpatialLocation,rowguid,ModifiedDate")] Address address)
        {
            if (ModelState.IsValid)
            {
                db.Addresses.Add(address);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StateProvinceID = new SelectList(db.StateProvinces, "StateProvinceID", "StateProvinceCode", address.StateProvinceID);
            return(View(address));
        }
        public ActionResult Create([Bind(Include = "BusinessEntityID,rowguid,ModifiedDate,isDeleted")] BusinessEntity businessEntity)
        {
            if (ModelState.IsValid)
            {
                db.BusinessEntities.Add(businessEntity);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BusinessEntityID = new SelectList(db.People, "BusinessEntityID", "FirstName", businessEntity.BusinessEntityID);
            return(View(businessEntity));
        }
        public ActionResult Create([Bind(Include = "BusinessEntityID,AddressID,AddressTypeID,rowguid,ModifiedDate")] BusinessEntityAddress businessEntityAddress)
        {
            if (ModelState.IsValid)
            {
                db.BusinessEntityAddresses.Add(businessEntityAddress);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AddressID = new SelectList(db.Addresses, "AddressID", "AddressLine1", businessEntityAddress.AddressID);
            return(View(businessEntityAddress));
        }
Beispiel #15
0
        public ActionResult Create([Bind(Include = "BusinessEntityID,PasswordHash,PasswordSalt,rowguid,ModifiedDate,isDeleted")] Password password)
        {
            if (ModelState.IsValid)
            {
                db.Passwords.Add(password);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BusinessEntityID = new SelectList(db.People, "BusinessEntityID", "PersonType", password.BusinessEntityID);
            return(View(password));
        }
Beispiel #16
0
        public ActionResult Create([Bind(Include = "JobCandidateID,BusinessEntityID,Resume,ModifiedDate,isDeleted")] JobCandidate jobCandidate)
        {
            if (ModelState.IsValid)
            {
                db.JobCandidates.Add(jobCandidate);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BusinessEntityID = new SelectList(db.Employees, "BusinessEntityID", "NationalIDNumber", jobCandidate.BusinessEntityID);
            return(View(jobCandidate));
        }
        public ActionResult Create([Bind(Include = "BusinessEntityID,NationalIDNumber,LoginID,OrganizationLevel,JobTitle,BirthDate,MaritalStatus,Gender,HireDate,SalariedFlag,VacationHours,SickLeaveHours,CurrentFlag,rowguid,ModifiedDate,isDeleted")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BusinessEntityID = new SelectList(db.People, "BusinessEntityID", "PersonType", employee.BusinessEntityID);
            return(View(employee));
        }
Beispiel #18
0
        public ActionResult Create([Bind(Include = "ProductID,ModifiedDate,isDeleted")] ProductDocument productDocument)
        {
            if (ModelState.IsValid)
            {
                db.ProductDocuments.Add(productDocument);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "Name", productDocument.ProductID);
            return(View(productDocument));
        }
Beispiel #19
0
        public ActionResult Create([Bind(Include = "BusinessEntityID,EmailAddressID,EmailAddress1,rowguid,ModifiedDate,isDeleted")] EmailAddress emailAddress)
        {
            if (ModelState.IsValid)
            {
                db.EmailAddresses.Add(emailAddress);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BusinessEntityID = new SelectList(db.People, "BusinessEntityID", "PersonType", emailAddress.BusinessEntityID);
            return(View(emailAddress));
        }
        public ActionResult Create([Bind(Include = "ProductID,StartDate,EndDate,ListPrice,ModifiedDate,isDeleted")] ProductListPriceHistory productListPriceHistory)
        {
            if (ModelState.IsValid)
            {
                db.ProductListPriceHistories.Add(productListPriceHistory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "Name", productListPriceHistory.ProductID);
            return(View(productListPriceHistory));
        }
        public ActionResult Create([Bind(Include = "BusinessEntityID,TerritoryID,SalesQuota,Bonus,CommissionPct,SalesYTD,SalesLastYear,rowguid,ModifiedDate,isDeleted")] SalesPerson salesPerson)
        {
            if (ModelState.IsValid)
            {
                db.SalesPersons.Add(salesPerson);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BusinessEntityID = new SelectList(db.Employees, "BusinessEntityID", "NationalIDNumber", salesPerson.BusinessEntityID);
            ViewBag.TerritoryID      = new SelectList(db.SalesTerritories, "TerritoryID", "Name", salesPerson.TerritoryID);
            return(View(salesPerson));
        }
        public ActionResult Create([Bind(Include = "BusinessEntityID,CreditCardID,ModifiedDate,isDeleted")] PersonCreditCard personCreditCard)
        {
            if (ModelState.IsValid)
            {
                db.PersonCreditCards.Add(personCreditCard);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BusinessEntityID = new SelectList(db.People, "BusinessEntityID", "PersonType", personCreditCard.BusinessEntityID);
            ViewBag.CreditCardID     = new SelectList(db.CreditCards, "CreditCardID", "CardType", personCreditCard.CreditCardID);
            return(View(personCreditCard));
        }
        public ActionResult Create([Bind(Include = "ProductID,LocationID,Shelf,Bin,Quantity,rowguid,ModifiedDate,isDeleted")] ProductInventory productInventory)
        {
            if (ModelState.IsValid)
            {
                db.ProductInventories.Add(productInventory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.LocationID = new SelectList(db.Locations, "LocationID", "Name", productInventory.LocationID);
            ViewBag.ProductID  = new SelectList(db.Products, "ProductID", "Name", productInventory.ProductID);
            return(View(productInventory));
        }
Beispiel #24
0
        public ActionResult Create([Bind(Include = "BusinessEntityID,PhoneNumber,PhoneNumberTypeID,ModifiedDate,isDeleted")] PersonPhone personPhone)
        {
            if (ModelState.IsValid)
            {
                db.PersonPhones.Add(personPhone);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BusinessEntityID  = new SelectList(db.People, "BusinessEntityID", "PersonType", personPhone.BusinessEntityID);
            ViewBag.PhoneNumberTypeID = new SelectList(db.PhoneNumberTypes, "PhoneNumberTypeID", "Name", personPhone.PhoneNumberTypeID);
            return(View(personPhone));
        }
        public ActionResult Create([Bind(Include = "CountryRegionCode,CurrencyCode,ModifiedDate,isDeleted")] CountryRegionCurrency countryRegionCurrency)
        {
            if (ModelState.IsValid)
            {
                db.CountryRegionCurrencies.Add(countryRegionCurrency);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CountryRegionCode = new SelectList(db.CountryRegions, "CountryRegionCode", "Name", countryRegionCurrency.CountryRegionCode);
            ViewBag.CurrencyCode      = new SelectList(db.Currencies, "CurrencyCode", "Name", countryRegionCurrency.CurrencyCode);
            return(View(countryRegionCurrency));
        }
        public ActionResult Create([Bind(Include = "SalesOrderID,SalesOrderDetailID,CarrierTrackingNumber,OrderQty,ProductID,SpecialOfferID,UnitPrice,UnitPriceDiscount,LineTotal,rowguid,ModifiedDate,isDeleted")] SalesOrderDetail salesOrderDetail)
        {
            if (ModelState.IsValid)
            {
                db.SalesOrderDetails.Add(salesOrderDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SalesOrderID   = new SelectList(db.SalesOrderHeaders, "SalesOrderID", "SalesOrderNumber", salesOrderDetail.SalesOrderID);
            ViewBag.SpecialOfferID = new SelectList(db.SpecialOfferProducts, "SpecialOfferID", "SpecialOfferID", salesOrderDetail.SpecialOfferID);
            return(View(salesOrderDetail));
        }
Beispiel #27
0
        public ActionResult Create([Bind(Include = "BusinessEntityID,PersonType,NameStyle,Title,FirstName,MiddleName,LastName,Suffix,EmailPromotion,AdditionalContactInfo,Demographics,rowguid,ModifiedDate")] Person person)
        {
            if (ModelState.IsValid)
            {
                db.People.Add(person);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BusinessEntityID = new SelectList(db.BusinessEntities, "BusinessEntityID", "BusinessEntityID", person.BusinessEntityID);
            ViewBag.BusinessEntityID = new SelectList(db.Employees, "BusinessEntityID", "NationalIDNumber", person.BusinessEntityID);
            return(View(person));
        }
Beispiel #28
0
        public ActionResult Create([Bind(Include = "PurchaseOrderID,PurchaseOrderDetailID,DueDate,OrderQty,ProductID,UnitPrice,LineTotal,ReceivedQty,RejectedQty,StockedQty,ModifiedDate,isDeleted")] PurchaseOrderDetail purchaseOrderDetail)
        {
            if (ModelState.IsValid)
            {
                db.PurchaseOrderDetails.Add(purchaseOrderDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductID       = new SelectList(db.Products, "ProductID", "Name", purchaseOrderDetail.ProductID);
            ViewBag.PurchaseOrderID = new SelectList(db.PurchaseOrderHeaders, "PurchaseOrderID", "PurchaseOrderID", purchaseOrderDetail.PurchaseOrderID);
            return(View(purchaseOrderDetail));
        }
        public ActionResult Create([Bind(Include = "BillOfMaterialsID,ProductAssemblyID,ComponentID,StartDate,EndDate,UnitMeasureCode,BOMLevel,PerAssemblyQty,ModifiedDate,isDeleted")] BillOfMaterial billOfMaterial)
        {
            if (ModelState.IsValid)
            {
                db.BillOfMaterials.Add(billOfMaterial);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ComponentID       = new SelectList(db.Products, "ProductID", "Name", billOfMaterial.ComponentID);
            ViewBag.ProductAssemblyID = new SelectList(db.Products, "ProductID", "Name", billOfMaterial.ProductAssemblyID);
            return(View(billOfMaterial));
        }
        public ActionResult Create([Bind(Include = "BusinessEntityID,Name,SalesPersonID,Demographics,rowguid,ModifiedDate,isDeleted")] Store store)
        {
            if (ModelState.IsValid)
            {
                db.Stores.Add(store);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BusinessEntityID = new SelectList(db.BusinessEntities, "BusinessEntityID", "BusinessEntityID", store.BusinessEntityID);
            ViewBag.SalesPersonID    = new SelectList(db.SalesPersons, "BusinessEntityID", "BusinessEntityID", store.SalesPersonID);
            return(View(store));
        }