示例#1
0
        public ActionResult AdminStart(int id, string search, string season)
        {
            VMAdmin vmad    = new VMAdmin();
            user    theuser = new user();

            theuser = dbc.GetUser(id);

            HttpCookie Newcookie = Request.Cookies["User"];

            if (Newcookie != null)
            {
                if (Newcookie.Value == id.ToString())
                {
                    Newcookie.Value   = theuser.userID.ToString();
                    Newcookie.Expires = DateTime.Now.AddHours(5);
                    HttpContext.Response.SetCookie(Newcookie);



                    TempData["username"] = theuser.username;
                    TempData["userID"]   = theuser.userID;
                    TempData["price"]    = theuser.fk_access_id.ToString();
                    List <tire> tirelist = dbc.GetAlltires(search, season);
                    List <user> UserList = dbc.GetAllUsers();
                    news        thenews  = dbc.GetTheNews(1);

                    //foreach (var u in UserList)
                    //{
                    //    vmad.UserList.Add(u);
                    //}
                    //foreach (var t in tirelist)
                    //{
                    //    vmad.TireList.Add(t);
                    //}
                    vmad.TireList = tirelist;
                    vmad.UserList = UserList;
                    vmad.News     = thenews;
                    try
                    {
                        return(View(vmad));
                    }
                    catch (Exception)
                    {
                        return(View());
                    }
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult MyInfo()
        {
            if (verifyAdmin() == false)
            {
                TempData["WarningMessage"] = "Don't go to places you are not allowed.";
                return(RedirectToAction("LogOut", "Home"));
            }
            AdminDAL     admDAL   = new AdminDAL();
            var          tempID   = Session["AdminLoggedIn"].ToString();
            List <Admin> admins   = (from x in admDAL.Admins where x.userName.Equals(tempID) select x).ToList <Admin>();
            VMAdmin      myAdmins = new VMAdmin();

            myAdmins.Admins = admins;
            //ViewBag.TempDoc = doc;
            return(View(myAdmins));
        }