public ActionResult Create([Bind(Include = "ID,ParentID,Name,IsActive,CreateDate,CreateUserID,UpgdateDate,UpdateUserID")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
        public ActionResult Create([Bind(Include = "ID,Name,LastName,Email,Telephone,Password,TCKN,IsActive,IsAdmin,CreateDate,CreateUserID,UpgdateDate,UpdateUserID")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
        public ActionResult Create([Bind(Include = "ID,Name,CategoryID,Brand,Model,ImageUrl,Description,Price,Tax,Discount,Stock,IsActive,CreateDate,CreateUserID,UpgdateDate,UpdateUserID")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name", product.CategoryID);
            return(View(product));
        }
        public ActionResult Create([Bind(Include = "ID,UserID,UserAddressID,StatusID,TotalProductPrice,TotalTaxPrice,TotalDiscount,TotalPrice,CreateDate,CreateUserID,UpgdateDate,UpdateUserID")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StatusID      = new SelectList(db.Statuses, "ID", "Name", order.StatusID);
            ViewBag.UserID        = new SelectList(db.Users, "ID", "Name", order.UserID);
            ViewBag.UserAddressID = new SelectList(db.Addresses, "ID", "Title", order.UserAddressID);
            return(View(order));
        }
        public ActionResult CreateOrder(int id) //addresslist.cshtml içinde idyi verdik.
        {
            var   db    = new MvcDB();
            var   sepet = db.Baskets.Include("Product").Where(x => x.UserID == LoginUserID).ToList();//ürünün fiyatı vs hepsi lazım olacak o yüzden include ettik.
            Order order = new Order();

            order.CreateDate        = DateTime.Now;
            order.CreateUserID      = LoginUserID;
            order.StatusID          = 1;
            order.TotalProductPrice = sepet.Sum(x => x.Product.Price);
            order.TotalTaxPrice     = sepet.Sum(x => x.Product.Tax);
            order.TotalDiscount     = sepet.Sum(x => x.Product.Discount);
            order.TotalPrice        = order.TotalProductPrice + order.TotalTaxPrice;
            order.UserAddressID     = id;
            order.UserID            = LoginUserID;

            order.OrderProducts = new List <OrderProduct>();
            foreach (var item in sepet)
            {
                order.OrderProducts.Add(new OrderProduct {
                    CreateDate   = DateTime.Now,
                    CreateUserID = LoginUserID,
                    ProductID    = item.ProductID,
                    Quantity     = item.Quantity
                });
                db.Baskets.Remove(item);
            }
            db.Orders.Add(order);

            db.SaveChanges();
            return(RedirectToAction("Detail", new { id = order.ID }));
        }
        public ActionResult Delete(int id)
        {
            var db         = new MvcDB();
            var deleteitem = db.Baskets.Where(x => x.ID == id).FirstOrDefault();

            db.Baskets.Remove(deleteitem);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Pay(int id)
        {
            var db    = new MvcDB();
            var order = db.Orders.Where(x => x.ID == id).FirstOrDefault();

            order.StatusID = 8;
            db.SaveChanges();
            return(RedirectToAction("Detail", new { id = order.ID }));
        }
        public ActionResult CreateUserAddress(UserAddress entity)
        {
            entity.CreateDate   = DateTime.Now;
            entity.CreateUserID = LoginUserID;
            entity.IsActive     = true;
            entity.UserID       = LoginUserID;

            var db = new MvcDB();

            db.Addresses.Add(entity);
            db.SaveChanges();
            return(RedirectToAction("AddressList"));
        }
        public JsonResult AddProduct(int productID, int quantity)
        {
            var db = new MvcDB();

            db.Baskets.Add(new Core.Model.Entity.Basket
            {
                CreateDate   = DateTime.Now,
                CreateUserID = LoginUserID,
                ProductID    = productID,
                Quantity     = quantity,
                UserID       = LoginUserID
            });
            var rt = db.SaveChanges();

            return(Json(rt, JsonRequestBehavior.AllowGet));
        }
Пример #10
0
        public ActionResult CreateUser(User entity)
        {
            //burada verdiğim alanları createuser.cshtml pageinden sildiğim için burada veriyorum.
            try
            {
                entity.CreateDate   = DateTime.Now;
                entity.CreateUserID = 1;
                entity.IsActive     = true;
                entity.IsAdmin      = false;

                db.Users.Add(entity);
                db.SaveChanges();
                return(Redirect("/"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Пример #11
0
 public ActionResult UrunEkle(Urun urun)
 {
     db.Urun.Add(urun);
     db.SaveChanges();
     return(RedirectToAction("Urunler"));
 }