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 })); }
public ActionResult Detail(string title, int id) { var db = new AndDB(); var prod = db.Products.Where(x => x.ID == id).FirstOrDefault(); return(View(prod)); }
public List <Product> Get() { var db = new AndDB(); var data = db.Products.Where(x => x.IsActive == true).ToList(); return(data); }
public PartialViewResult GetMenu() { var db = new AndDB(); var menus = db.Categories.Where(x => x.ParentID == 0).ToList(); return(PartialView(menus)); }
public ActionResult Detail(int id) { var db = new AndDB(); var data = db.Orders.Include("OrderProducts").Include("OrderProducts.Product").Include("OrderPayments").Include("Status").Include("UserAdress").Include("User").Where(x => x.ID == id).FirstOrDefault(); return(View(data)); }
public ActionResult PaymentStep(int id) { var db = new AndDB(); var data = db.Adresses.Where(x => x.ID == id).ToList(); return(View(data)); }
public ActionResult Index() { var db = new AndDB(); var data = db.Baskets.Include("Products").Where(x => x.UserID == LoginUserID).ToList(); return(View(data)); }
public ActionResult Index() { var db = new AndDB(); var data = db.Orders.Include("Status").Where(x => x.UserID == LoginUserID).ToList(); return(View(data)); }
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 })); }
public Product Get(int id) { var db = new AndDB(); var data = db.Products.Where(x => x.ID == id).FirstOrDefault(); return(data); }
public ActionResult AddressList() { var db = new AndDB(); var data = db.UserAddresses.Where(x => x.UserID == LoginUserID).ToList(); return(View(data)); }
public ActionResult Index() { AndDB db = new AndDB(); var data = db.Users.Where(x => x.ID == LoginUserID); return(View(data)); }
public ActionResult Index() { var db = new AndDB(); var data = db.Baskets.Include("Product").Where(x => x.UserID == LoginUserID).ToList();//include ile inner join yaptim return(View(data)); }
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)); }
public ActionResult Index(string isim, int id) { var db = new AndDB(); var data = db.Products.Where(x => x.IsActive == true && x.CategoryID == id).ToList(); ViewBag.category = db.Categories.Where(x => x.ID == id).FirstOrDefault(); return(View(data)); }
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 })); }
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 CreateUserAddress(UserAddress entity) { entity.CreateDate = DateTime.Now; entity.CreateUserID = LoginUserID; entity.IsActive = true; entity.UserID = LoginUserID; var db = new AndDB(); db.UserAddresses.Add(entity); db.SaveChanges(); return(RedirectToAction("AddressList")); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { using (AndDB db = new AndDB()) { var email = value as string; if (db.Users.Any(u => u.Email == email)) { return(new ValidationResult("This email has been taken.")); } } return(ValidationResult.Success); }
public User Login(string email, string password) { var db = new AndDB(); var usr = db.Users.Where(x => x.EMail == email && x.Password == password && x.IsActive == true).ToList(); if (usr.Count > 0) { return(usr.FirstOrDefault()); } else { return(null); } }
public JsonResult AddProduct(int productID, int quantity) { var db = new AndDB(); 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)); }
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()); } }
//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")); }
public ActionResult Login(string EMail, string Password) { var db = new AndDB(); var users = db.Users.Where(x => x.EMail == EMail && x.Password == Password && x.IsActive == true && x.IsAdmin == false).ToList(); if (users.Count == 1) { Session["LoginUserID"] = users.FirstOrDefault().ID; Session["LoginUser"] = users.FirstOrDefault(); return(Redirect("/")); } else { ViewBag.Error = "Hatalı kullanıcı veya şifre"; return(View()); } }
public ActionResult Index() { var db = new AndDB(); var data = db.Baskets.Include("Product").Where(x => x.UserID == LoginUserID).ToList(); //Sepetim Ekranındaki Ara Toplam değerini getirir... int tax = ((int)data.Sum(x => x.Product.Price) * (int)data.Sum(x => x.Product.Tax)) / 100; ViewBag.subtax = tax.ToString("##,## ₺"); int subtotal = ((int)data.Sum(x => x.Product.Price) * (100 - (int)data.Sum(x => x.Product.Tax))) / 100; ViewBag.subtotal = subtotal.ToString("##,## ₺"); ViewBag.discount = data.Sum(x => x.Product.Discount).ToString("##,## ₺"); ViewBag.total = data.Sum(x => x.Product.Price).ToString("##,## ₺"); return(View(data)); }