Ejemplo n.º 1
0
 public ActionResult CreateUserAddress(UserAddress entity)
 {
     entity.CreateDate   = DateTime.Now;
     entity.CreateUserID = LoginUserID;
     entity.IsActive     = true;
     entity.UserID       = LoginUserID;
     db.UserAddresses.Add(entity);
     db.SaveChanges();
     return(RedirectToAction("AddressList"));
 }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "ID,ParentID,Name,IsActive,CreateDate,CreateUserID,UpdateDate,UpdateUserID")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

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

            return(View(user));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "ID,Adi,CategoryID,marka,model,imageUrl,Açıklama,fiyat,vergi,stok,indirim,IsActive,CreateDate,CreateUserID,UpdateDate,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));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "ID,Name,CategoryID,Brand,Model,ImageUrl,Description,Price,Discount,Tax,Stock,IsActive,CreateDate,CreateUserID,UpdateDate,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,UpdateDate,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));
        }
Ejemplo n.º 7
0
        public JsonResult AddProduct(int productID, int quantity)
        {
            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));
        }
Ejemplo n.º 8
0
        public ActionResult CreateOrder(int id)
        {
            var db = new AndDB();


            var   sepet = db.Baskets.Include("Product").Where(x => x.UserID == LoginUserID).ToList();;
            Order order = new Order();

            order.CreateDate        = DateTime.Now;
            order.CreateUserID      = LoginUserID;
            order.StatusID          = 2;
            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,
                    ProdcutID    = item.ProductID,
                    Quantity     = item.Quantity
                });
                db.Baskets.Remove(item);
            }
            db.Orders.Add(order);

            db.SaveChanges();

            return(RedirectToAction("Detail", new { id = order.ID }));
        }
Ejemplo n.º 9
0
        public JsonResult AddProduct(int productID)
        {
            var    db = new AndDB();
            Basket basket;

            if (db.Baskets.Any(b => b.ProductID == productID && b.UserID == this.LoginUserID))
            {
                basket = db.Baskets.FirstOrDefault(b => b.ProductID == productID && b.UserID == this.LoginUserID);
                basket.Quantity++;
            }
            else
            {
                basket = new Basket()
                {
                    CreateDate   = DateTime.Now.Date,
                    CreateUserID = this.LoginUserID,
                    ProductID    = productID,
                    Quantity     = 1,
                    UserID       = this.LoginUserID,
                };
                db.Baskets.Add(basket);
            }
            var result = db.SaveChanges();

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 10
0
        public ActionResult RemoveAvatar()
        {
            var currentUser = this.LoginUserEntity;

            if (currentUser != null)
            {
                var userInDb = db.Users.FirstOrDefault(u => u.ID == this.LoginUserID);
                if (userInDb != null)
                {
                    userInDb.ImageUrl = "no-user.png";
                    db.SaveChanges();
                    Session["LoggedUser"] = userInDb;
                }
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 11
0
        public ActionResult CreateOrder(int ID)
        {
            var db = new AndDB();


            var   sepet = db.Baskets.Include("Product").Where(x => x.UserID == LoginUserID).ToList();;
            Order order = new Order();

            order.CreateDate      = DateTime.Now;
            order.CreateUserID    = LoginUserID;
            order.StatusID        = 2;
            order.ToplamUrunFiyat = sepet.Sum(x => x.Product.fiyat);
            order.ToplamVergi     = sepet.Sum(x => x.Product.vergi);
            order.ToplamIndirim   = sepet.Sum(x => x.Product.indirim);
            order.TopplamFiyat    = order.ToplamUrunFiyat + order.TopplamFiyat;
            order.UserAddressID   = ID;
            order.UserID          = LoginUserID;
            order.BasketDetail    = new List <BasketDetail>();
            foreach (var item in sepet)
            {
                order.BasketDetail.Add(new BasketDetail
                {
                    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 }));
        }
Ejemplo n.º 12
0
        public ActionResult Delete(int id)
        {
            var db         = new AndDB();
            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 AndDB();
            var order = db.Orders.Where(x => x.ID == id).FirstOrDefault();

            order.StatusID = 6;
            db.SaveChanges();
            return(RedirectToAction("Detail", new { id = order.ID }));
        }
Ejemplo n.º 14
0
        public ActionResult Register(RegisterModel registerUser)
        {
            var user = new User
            {
                ImageUrl     = "no-user.png",
                IsActive     = true,
                IsAdmin      = false,
                CreateDate   = DateTime.Now.Date,
                CreateUserID = 1
            };

            if (ModelState.IsValid)
            {
                user.VerificationCode = Guid.NewGuid().ToString();
                user.IsEmailVerified  = false;

                // Sent Form
                registerUser.Password        = Crypto.Hash(registerUser.Password);
                registerUser.ComparePassword = Crypto.Hash(registerUser.ComparePassword);

                //Assigning values to real user which will be stored in database
                user.Name      = registerUser.Name;
                user.LastName  = registerUser.LastName;
                user.Email     = registerUser.Email;
                user.Password  = registerUser.Password;
                user.Telephone = registerUser.Telephone;

                db.Users.Add(user);
                db.SaveChanges();

                SendCode(user, user.Email, user.VerificationCode);
                ViewBag.Message = "Verification Link has been sent to your account. Please verify your account, otherwise you will not be able to enter your profile.";
                ViewBag.Status  = true;
            }
            else
            {
                ViewBag.Status = false;
            }
            return(View());
        }
Ejemplo n.º 15
0
 public ActionResult CreateUser(User entity)
 {
     try
     {
         entity.CreateDate   = DateTime.Now;
         entity.CreateUserID = 1;
         entity.IsActive     = true;
         db.Users.Add(entity);
         db.SaveChanges();
         return(Redirect("/"));
     }
     catch (Exception ex)
     {
         return(View());
     }
 }
        public JsonResult AddProduct(int productID, int quantity)
        {
            var db = new AndDB();

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

            return(Json(rt, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 17
0
 public ActionResult CreateUser(User user)
 {
     try {
         user.CreateDate   = DateTime.Now;
         user.CreateUserID = 1;
         user.IsActive     = true;
         user.IsAdmin      = false;
         var db = new AndDB();
         db.Users.Add(user);
         db.SaveChanges();
         return(Redirect("/"));
     }
     catch (Exception ex) {
         return(View());
     }
 }
Ejemplo n.º 18
0
        //public ActionResult Delete(int id)
        //{
        //    var db = new AndDB();
        //    if (db.Baskets.Any(b => b.ProductID == id && b.UserID == this.LoginUserID))
        //    {
        //        var basket = db.Baskets.FirstOrDefault(b => b.ProductID == id && b.UserID == this.LoginUserID);
        //        db.Baskets.Remove(basket);
        //        db.SaveChanges();
        //    }
        //    return RedirectToAction("Index");
        //}
        public ActionResult Decrease(int id)
        {
            var db           = new AndDB();
            var decreaseItem = db.Baskets.Where(x => x.ID == id).FirstOrDefault();

            if (decreaseItem.Quantity >= 1)
            {
                decreaseItem.Quantity--;
                if (decreaseItem.Quantity == 0)
                {
                    db.Baskets.Remove(decreaseItem);
                }
            }
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }