Example #1
0
        public ActionResult Index()
        {
            dbshopgameEntities db      = new dbshopgameEntities();
            List <Product>     listpro = db.Products.Take(10).ToList <Product>();

            return(View(listpro));
        }
Example #2
0
        //[ChildActionOnly]
        public ActionResult getCategory()
        {
            dbshopgameEntities db          = new dbshopgameEntities();
            List <Category>    listDanhMuc = db.Categories.ToList <Category>();

            return(PartialView(listDanhMuc));
        }
Example #3
0
        public ActionResult ListProduct(int Iddanhmuc)
        {
            dbshopgameEntities db          = new dbshopgameEntities();
            List <Product>     listProduct = db.Products.Where(p => p.ID_DanhMuc == Iddanhmuc).ToList();

            return(View(listProduct));
        }
Example #4
0
        public ActionResult ProductDetail(int Iddetail)
        {
            dbshopgameEntities db        = new dbshopgameEntities();
            Product            prodetail = db.Products.Where(p => p.ID_SanPham == Iddetail).SingleOrDefault();

            return(View(prodetail));
        }
Example #5
0
        public ActionResult Register(RegisterModel user)
        {
            try
            {
                dbshopgameEntities db = new dbshopgameEntities();
                if (ModelState.IsValid == true)
                {
                    UserManager usermanager = new UserManager();
                    if (usermanager.checkUserName(user.username) == false && usermanager.checkEmail(user.email) == false)/*chưa tồn tại nên tạo mới*/
                    {
                        Account newuser = new Account();
                        newuser.UserName = user.username;
                        newuser.Name     = user.name;
                        newuser.Password = user.password;
                        newuser.Email    = user.email;
                        //newuser.SĐT = user.SĐT;
                        //newuser.DiaChi = user.DiaChi;

                        //mã hóa password
                        SHA256 md5           = new SHA256CryptoServiceProvider();
                        Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(newuser.Password);
                        Byte[] encodedBytes  = md5.ComputeHash(originalBytes);
                        newuser.Password = BitConverter.ToString(encodedBytes);

                        db.Accounts.Add(newuser);
                        db.SaveChanges();
                        //ViewBag.dangkythanhcong = "Đã đăng ký thành công";
                        //return View();
                        Session["Register"] = "Đăng kí thành công";
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        //return View("FailRegister");
                        ModelState.AddModelError("RegisterFail", "Tài khoản đã tồn tại");
                        ViewBag.error = "Tai khoan da ton tai";
                    }
                    ViewBag.dangkythanhcong = "đã đăng ký thành công";
                }
            }
            catch (Exception ex)
            {
            }
            return(View());
        }