Esempio n. 1
0
        public IActionResult ThanhToan(string name, string email, string address, string tel)
        {
            List <GioHang> danhsachhang = SessionHelper.GetObjectFromJson <List <GioHang> >(HttpContext.Session, "cart");

            CreateInvoice(danhsachhang, name, email, address, tel);
            HttpContext.Session.SetString("cart", "");

            foreach (var item in danhsachhang)
            {
                var topselling = eMarketContext.TopSelling.Where(p => p.HangHoaId == item.HangHoa.HangHoaId).FirstOrDefault();
                if (topselling == null)
                {
                    var newcolumn = new TopSelling();
                    newcolumn.HangHoaId = item.HangHoa.HangHoaId;
                    newcolumn.SoLan     = 1;
                    eMarketContext.Add(newcolumn);
                    eMarketContext.SaveChanges();
                }
                else
                {
                    topselling.SoLan += 1;
                    eMarketContext.Update(topselling);
                    eMarketContext.SaveChanges();
                }
            }

            TempData["status"] = "Đặt Hàng Thành Công";
            return(RedirectToAction("Index", "HangHoa"));
        }
Esempio n. 2
0
        public IActionResult AddNewRating(int id, string comment, int rating)
        {
            var username = HttpContext.Session.GetString("User");
            int ratingid = id;

            if (username == null || username == "")
            {
                TempData["loginError"] = "Bạn cần đăng nhập để sử dụng chức năng này";
                return(RedirectToAction("Details", "HangHoa", new { id = id }));
            }
            var user      = eMarketContext.TaiKhoan.Where(p => p.UserName == username).FirstOrDefault();
            var newRating = new DanhGia();

            newRating.Comment    = comment;
            newRating.HangHoaId  = id;
            newRating.TaiKhoanId = user.TaiKhoanId;
            newRating.Rating     = rating;
            eMarketContext.Add(newRating);
            eMarketContext.SaveChanges();
            return(RedirectToAction("Index", "HangHoa"));
        }
Esempio n. 3
0
 public IActionResult ChangeInfo([Bind("ThongTinTaiKhoanId", "TaiKhoanId", "HoVaTen", "NgaySinh", "Sdt", "DiaChi")] ThongTinTaiKhoan info)
 {
     _context.Update(info);
     _context.SaveChanges();
     return(RedirectToAction("Index", "HangHoa"));
 }