Exemple #1
0
 // GET: MyProject
 public ActionResult Index()
 {
     using (mydatabase db = new mydatabase())
     {
         return(View(db.Users.ToList()));
         //return View("Home");
     }
 }
Exemple #2
0
 public ActionResult news()
 {
     using (mydatabase db = new mydatabase())
     {
         return(View(db.Items.ToList()));
         //return View("Home");
     }
 }
Exemple #3
0
 public ActionResult nammuoicho()
 {
     using (mydatabase db = new mydatabase())
     {
         var itemlist      = db.Items.Where(x => x.Category_id == 5).ToList();
         var category_item = db.Categories.Where(x => x.Id == 5);
         var List4         = new data_return_car();
         List4.items             = itemlist;
         List4.category_eachitem = category_item.Single();
         return(View(List4));
     }
 }
Exemple #4
0
        public ActionResult boncho()
        {
            using (mydatabase db = new mydatabase())
            {
                //List<Item> itemlist = new List<Item>();

                //itemlist = db.Items.Where(x => x.Category_id == 1).ToList();
                var itemlist      = db.Items.Where(x => x.Category_id == 1).ToList();
                var category_item = db.Categories.Where(x => x.Id == 1);
                var List          = new data_return_car();
                List.items             = itemlist;
                List.category_eachitem = category_item.Single();
                return(View(List));
            }
        }
Exemple #5
0
 public ActionResult login(User user)
 {
     using (mydatabase checkuser = new mydatabase())
     {
         var usr = checkuser.Users.Where(u => u.username == user.username && u.password == user.password).FirstOrDefault();
         if (usr != null)
         {
             //Session["userID"] = usr.Id.ToString();
             Session["UserName"]  = usr.username.ToString();
             Session["User_role"] = usr.role.ToString();
             return(RedirectToAction("Index"));
         }
         else
         {
             ModelState.AddModelError("", "Username or Password is wrong");
         }
     }
     return(View());
 }
Exemple #6
0
        public ActionResult register(User user)
        {
            if (ModelState.IsValid)

            {
                var confirm = 0;
                using (mydatabase adduser = new mydatabase())
                {
                    if (user.password == user.confirmpassword)
                    {
                        var check = adduser.Users.Where(u => u.username == user.username).Count();

                        if (check == 0)
                        {
                            adduser.Users.Add(user);
                            adduser.SaveChanges();
                            confirm = 1;
                        }
                        else
                        {
                            ModelState.AddModelError("", "Username exists!!!");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Password and Confirm password is not same!!!");
                    }
                }
                if (confirm == 1)
                {
                    ModelState.Clear();
                    ViewBag.Message = user.username + " đăng kí thành công!";
                    return(RedirectToAction("login"));
                }
            }
            return(View());
        }
 public CustomRoleProvider()
 {
     db = new mydatabase();
 }