// GET: Dynamics
        public ActionResult Index()
        {
            var vm       = new DynamicsMultiViewModel();
            var dynamics = dynamicsBLL.GetDAL().GetALL();
            //var images = imagesBLL.GetDAL().GetKey(); //不能实现通过图片id进行查询?
            //var users = usersBLL.GetDAL().GetALL();
            IList <DynamicsViewModel> vmlist = new List <DynamicsViewModel>();

            foreach (var dynamic in dynamics)
            {
                var _user  = usersBLL.GetDAL().GetById(dynamic.UserId);
                var _image = _user.Images.SingleOrDefault();
                vmlist.Add
                    (new DynamicsViewModel
                {
                    dynamic = dynamic,
                    user    = _user,
                    image   = _image,
                }
                    );
            }

            vm.DynamicsViewModels = vmlist;
            return(View(vm));
        }
        public ActionResult Index()
        {
            var images     = imagesBLL.GetDAL().GetALL();
            var dynamics   = dynamicsBLL.GetDAL().GetList(3, 1);
            var users      = usersBLL.GetDAL().GetList(3, 1);
            var activities = activitiesBLL.GetDAL().GetList(3, 1);

            Models.HomeIndexViewModel homevm = new Models.HomeIndexViewModel();
            homevm.Images     = images;
            homevm.Dynamics   = dynamics;
            homevm.Users      = users;
            homevm.Activities = activities;
            return(View(homevm));
        }
Esempio n. 3
0
        public ActionResult Login([Bind(Include = "UserName,Password")] string UserName, string Password)
        {
            var users = usersBLL.GetDAL().Denglu(UserName, Password);

            if (users != null)
            {
                //保存到Session HttpContext.
                Session["UserId"] = users.UserId;
                //Session["UserName"] = UserName;
                //Session["Password"] = Password;
                Session["User"] = users;
                return(Content("<script>alert('登录成功!');window.location.href='/'</script>"));
            }
            else
            {
                return(Content("<script>;alert('登录失败!');history.go(-1)</script>"));
            }
        }
Esempio n. 4
0
        public ActionResult Register([Bind(Include = "UsersName,Password,Email")] Users users)
        {
            if (ModelState.IsValid)
            {
                //users.UserName = null;
                //users.Password = null;
                //users.Email = null;
                //Users  users = usersBLL.GetDAL().Add(users);

                UsersBLL ii = new UsersBLL();
                var      uu = ii.GetDAL().AddUser(users);

                return(Content("<script>;alert('注册成功!');window.location.href='/Users/Login';</script>"));
            }
            else
            {
                return(Content("<script>;alert('注册失败!');history.go(-1)</script>"));
            }
        }