public ActionResult Create([Bind("ProductName", "ProductPrice", "ProductImage", "ProductQuantity", "ProductSize", "ProductDescription", "CategoryId", "VendorId", "BrandId")] Products c)
 {
     if (ModelState.IsValid)
     {
         context.Products.Add(c);
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(c));
 }
Exemple #2
0
 public ActionResult Create([Bind("ProductName", "ProductPrice", "ProductQuantity", "ProductSize")] Products c)
 {
     if (ModelState.IsValid)
     {
         context.Products.Add(c);
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(c));
 }
 public ActionResult Create([Bind("VendorName", "VendorEmail", "VendorPhoneNo")] Vendors V)
 {
     if (ModelState.IsValid)
     {
         context.Vendors.Add(V);
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(V));
 }
Exemple #4
0
 public ActionResult Create([Bind("CategoryName")] Categories C)
 {
     if (ModelState.IsValid)
     {
         context.Categories.Add(C);
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(C));
 }
Exemple #5
0
        public ActionResult Create([Bind("BrandName")] Brands B)
        {
            if (ModelState.IsValid)
            {
                context.Brands.Add(B);
                context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(B));
        }
Exemple #6
0
        public IActionResult EditProfile(int id, Customers customers)
        {
            Customers customer1 = SessionHelper.GetObjectFromJson <Customers>(HttpContext.Session, "cus");
            Customers customer  = context.Customers.Where(x => x.Email == customer1.Email).SingleOrDefault();

            customer.CustomerFirstName    = customers.CustomerFirstName;
            customer.CustomerLastName     = customers.CustomerLastName;
            customer.UserName             = customers.UserName;
            customer.Gender               = customers.Gender;
            customer.PhoneNumber          = customers.PhoneNumber;
            customer.Country              = customers.Country;
            customer.State                = customers.State;
            customer.ZipCode              = customers.ZipCode;
            customer.Address              = customers.Address;
            customer.Address2             = customers.Address2;
            customer.AlternatePhoneNumber = customers.AlternatePhoneNumber;
            customer.Country2             = customers.Country2;
            customer.State2               = customers.State2;
            customer.ZipCode2             = customers.ZipCode2;
            context.SaveChanges();
            return(RedirectToAction("userProfile", "home", new { @id = customer.Email }));
        }
        public IActionResult Checkout(Customers customers)
        {
            var customer = context.Customers.Where(x => x.Email == customers.Email).SingleOrDefault();

            customer.CustomerFirstName    = customers.CustomerFirstName;
            customer.CustomerLastName     = customers.CustomerLastName;
            customer.UserName             = customers.UserName;
            customer.Gender               = customers.Gender;
            customer.Email                = customers.Email;
            customer.PhoneNumber          = customers.PhoneNumber;
            customer.Country              = customers.Country;
            customer.State                = customers.State;
            customer.ZipCode              = customers.ZipCode;
            customer.Address              = customers.Address;
            customer.Address2             = customers.Address2;
            customer.SameAddress          = customers.SameAddress;
            customer.AlternatePhoneNumber = customers.AlternatePhoneNumber;
            customer.Country2             = customers.Country2;
            customer.State2               = customers.State2;
            customer.ZipCode2             = customers.ZipCode2;

            context.SaveChanges();
            var    amount = TempData["total"];
            Orders orders = new Orders()
            {
                OrderAmount = Convert.ToSingle(amount),
                OrderDate   = DateTime.Now,
                CustomerId  = customer.CustomerId
            };

            context.Orders.Add(orders);
            context.SaveChanges();
            var cart = SessionHelper.GetObjectFromJson <List <Item> >(HttpContext.Session, "cart");
            List <OrderProducts> orderProducts = new List <OrderProducts>();

            for (int i = 0; i < cart.Count; i++)
            {
                OrderProducts orderProduct = new OrderProducts()
                {
                    OrderId   = orders.OrderId,
                    ProductId = cart[i].Products.ProductId,
                    Quantity  = cart[i].ItemQuantity
                };
                orderProducts.Add(orderProduct);
            }
            orderProducts.ForEach(n => context.OrderProducts.Add(n));
            context.SaveChanges();
            TempData["cust"] = customer.CustomerId;
            return(RedirectToAction("Status", "cart"));
        }
        public IActionResult Checkout([Bind("CustomerFirstName,CustomerLastName,UserName,Gender,Email,PhoneNumber,Country,State,ZipCode,Address,SameAddress", "Address2", "Country2", "State2", "ZipCode2", "AlternatePhoneNumber")] Customers customers, string stripeEmail, string stripeToken)
        {
            var customer = context.Customers.Where(x => x.Email == customers.Email).SingleOrDefault();

            customer.CustomerFirstName    = customers.CustomerFirstName;
            customer.CustomerLastName     = customers.CustomerLastName;
            customer.UserName             = customers.UserName;
            customer.Gender               = customers.Gender;
            customer.Email                = customers.Email;
            customer.PhoneNumber          = customers.PhoneNumber;
            customer.Country              = customers.Country;
            customer.State                = customers.State;
            customer.ZipCode              = customers.ZipCode;
            customer.Address              = customers.Address;
            customer.SameAddress          = customers.SameAddress;
            customer.Address2             = customers.Address2;
            customer.AlternatePhoneNumber = customers.AlternatePhoneNumber;
            customer.Country2             = customers.Country2;
            customer.State2               = customers.State2;
            customer.ZipCode2             = customers.ZipCode2;

            context.SaveChanges();
            var    amount = TempData["total"];
            Orders orders = new Orders()
            {
                OrderAmount = Convert.ToSingle(amount),
                OrderDate   = DateTime.Now,
                CustomerId  = customer.CustomerId
            };

            context.Orders.Add(orders);
            context.SaveChanges();
            var cart = SessionHelper.GetObjectFromJson <List <Item> >(HttpContext.Session, "cart");
            List <OrderProducts> orderProducts = new List <OrderProducts>();

            for (int i = 0; i < cart.Count; i++)
            {
                OrderProducts orderProduct = new OrderProducts()
                {
                    OrderId   = orders.OrderId,
                    ProductId = cart[i].Products.ProductId,
                    Quantity  = cart[i].ItemQuantity
                };
                orderProducts.Add(orderProduct);
            }
            orderProducts.ForEach(n => context.OrderProducts.Add(n));
            context.SaveChanges();

            TempData["cust"] = customer.CustomerId;
            StripeSettings ss = new StripeSettings()
            {
                PublishableKey = stripeEmail,
                SecretKey      = stripeToken
            };

            context.StripeSettings.Add(ss);
            context.SaveChanges();
            Payments p1 = new Payments()
            {
                OrderId          = orders.OrderId,
                Amount           = Convert.ToSingle(amount),
                PaymentDate      = DateTime.Today,
                CardDigit        = 1111,
                StripeSettingsId = ss.StripeSettingsId,
                CustomerId       = customer.CustomerId,
                Description      = "sucessfully done"
            };

            context.Payments.Add(p1);
            context.SaveChanges();

            return(RedirectToAction("status", "cart"));
        }