Beispiel #1
0
        public ActionResult seeblogdetails(int BlogID)                                                    //查看博文详情
        {
            Models.Blog           blog     = db.Blogs.Find(BlogID);                                       //找到博文
            Models.UserAccount    user     = db.UserAccounts.Find(blog.BloggerID);                        //找到博主的信息存好
            List <Models.Comment> comments = db.Comments.Where(m => m.BlogID == BlogID).ToList();         //吧博文的评论保存好
            List <Models.Focus>   fans     = db.Focuses.Where(m => m.Focused == blog.BloggerID).ToList(); //粉丝数
            List <Models.Focus>   focus    = db.Focuses.Where(m => m.DoFocus == blog.BloggerID).ToList(); //关注的人数
            int fancount   = fans.Count();
            int focuscount = focus.Count();

            //赞数和是否已经点赞过
            String             UserID     = Session["UserID"].ToString();
            List <Models.Like> likes      = db.Likes.Where(n => n.BlogID == BlogID).Where(m => m.UserID == UserID).ToList(); //判断用户是否点赞过
            double             likescount = db.Likes.Where(m => m.BlogID == BlogID).Count();                                 //所有的赞数

            ViewData["likescount"]   = likescount;
            ViewData["BloggerImage"] = user.UserImage;
            ViewData["BloggerID"]    = user.UserID;
            ViewData["userName"]     = user.UserName;
            ViewData["userID"]       = user.UserID;
            ViewData["fancount"]     = fancount;
            ViewData["focuscount"]   = focuscount;
            ViewBag.comments         = comments;
            return(View(blog));
        }
Beispiel #2
0
        public ActionResult seeuserdetails(String BloggerID)                                    //查看博主个人信息
        {
            Models.UserAccount  user  = db.UserAccounts.Find(BloggerID);                        //找到博主
            List <Models.Blog>  blogs = db.Blogs.Where(m => m.BloggerID == BloggerID).ToList(); //找到博主所有的博文
            List <Models.Focus> fans  = db.Focuses.Where(m => m.Focused == BloggerID).ToList(); //粉丝数
            List <Models.Focus> focus = db.Focuses.Where(m => m.DoFocus == BloggerID).ToList(); //关注的人数
            int fancount   = fans.Count();
            int focuscount = focus.Count();
            //判断是否已经关注此人
            String UserID = Session["UserID"].ToString();                                                                         //当前用户
            List <Models.Focus> focuses = db.Focuses.Where(n => n.DoFocus == UserID).Where(m => m.Focused == BloggerID).ToList(); //判断是否关注此人

            if (focuses.Count() == 0)                                                                                             //没有关注
            {
                ViewData["guanzhu"] = "关注";
            }
            else//关注了
            {
                ViewData["guanzhu"] = "取消关注";
            }

            ViewBag.blogs = blogs;

            ViewData["BloggerID"]  = BloggerID;
            ViewData["UserImage"]  = user.UserImage;
            ViewData["UserName"]   = user.UserName;
            ViewData["fancount"]   = fancount;
            ViewData["focuscount"] = focuscount;
            return(View(user));
        }
        public IResponse <bool> Update(Models.UserAccount model, params string[] values)
        {
            var response = new IResponse <bool>()
            {
                Status = true
            };
            var entity = Mapper.Map <Entity.UserAccount>(model);

            response.Result = repository.Update(entity, CurrentUserSession.UserId, values);
            return(response);
        }
Beispiel #4
0
        public ActionResult Write()//写博文
        {
            string BloggerID = Session["UserID"].ToString();

            Models.UserAccount user = db.UserAccounts.Find(BloggerID);//找到用户
            if (user.status == false)
            {
                return(Content("<script>alert('该账户已处于锁定状态,解锁请与管理员联系!');window.open('" + Url.Content("~/User/Index") + "', '_self')</script>"));
            }
            else
            {
                return(View());
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public IResponse <Models.UserAccount> Create(Models.UserAccount model)
        {
            var entity = repository.Add(Mapper.Map <Entity.UserAccount>(model), CurrentUserSession.UserId);

            if (entity == null)
            {
                return(new IResponse <Models.UserAccount> {
                    Status = false, ErrCode = ErrorMessage.DataNotExist.Code, ErrMsg = ErrorMessage.DataNotExist.Msg
                });
            }
            return(new IResponse <Models.UserAccount> {
                Status = true, Result = Mapper.Map <Models.UserAccount>(entity)
            });
        }
Beispiel #6
0
 public ActionResult Lock(string UserID)
 {
     Models.UserAccount user = db.UserAccounts.Find(UserID);//找到用户
     if (ModelState.IsValid)
     {
         user.status          = false;
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(Content("<script>alert('锁定用户成功!');window.open('" + Url.Content("~/Admin/Lock") + "', '_self')</script>"));
     }
     else
     {
         return(Content("<script>alert('锁定用户失败!');window.open('" + Url.Content("~/Admin/Lock") + "', '_self')</script>"));
     }
 }
Beispiel #7
0
        public ActionResult Lock()
        {
            List <Models.UserAccount> userAccountModels = db.UserAccounts.ToList();//显示数据库中所有的用户

            Models.UserAccount admin = db.UserAccounts.Find("admin");
            userAccountModels.Remove(admin);//除去管理员
            if (userAccountModels.Count != 0)
            {
                return(View(userAccountModels));
            }
            else
            {
                return(View());
            }
        }
Beispiel #8
0
        public ActionResult ViewUsers(String UserID)                                         //查看用户个人信息
        {
            Models.UserAccount user  = db.UserAccounts.Find(UserID);                         //找到用户
            List <Models.Blog> blogs = db.Blogs.Where(m => m.BloggerID == UserID).ToList();  //找到用户所有的博文

            List <Models.Focus> fans  = db.Focuses.Where(m => m.Focused == UserID).ToList(); //粉丝数
            List <Models.Focus> focus = db.Focuses.Where(m => m.DoFocus == UserID).ToList(); //关注的人数
            int fancount   = fans.Count();
            int focuscount = focus.Count();

            ViewBag.blogs          = blogs;
            ViewData["fancount"]   = fancount;
            ViewData["focuscount"] = focuscount;
            return(View(user));
        }
Beispiel #9
0
        public ActionResult seeblogdetails(int BlogID)                                              //查看博文详情
        {
            Models.Blog         blog      = db.Blogs.Find(BlogID);                                  //找到博文
            Models.UserAccount  user      = db.UserAccounts.Find(blog.BloggerID);                   //找到博主的信息存好
            string              BloggerID = user.UserID;
            List <Models.Focus> fans      = db.Focuses.Where(m => m.Focused == BloggerID).ToList(); //粉丝数
            List <Models.Focus> focus     = db.Focuses.Where(m => m.DoFocus == BloggerID).ToList(); //关注的人数
            int fancount   = fans.Count();
            int focuscount = focus.Count();

            List <Models.Comment> comments = db.Comments.Where(m => m.BlogID == BlogID).ToList();//吧博文的评论保存好

            //赞数和是否已经点赞过
            String             UserID     = Session["UserID"].ToString();
            List <Models.Like> likes      = db.Likes.Where(n => n.BlogID == BlogID).Where(m => m.UserID == UserID).ToList(); //判断用户是否点赞过
            double             likescount = db.Likes.Where(m => m.BlogID == BlogID).Count();                                 //所有的赞数

            if (likes.Count() == 0)                                                                                          //没赞过设置buttom的颜色
            {
                ViewData["background"] = "white";
            }
            else
            {//用户已经赞过 设置颜色
                ViewData["background"] = "pink";
            }
            //判断是否已经关注此人
            List <Models.Focus> focuses = db.Focuses.Where(n => n.DoFocus == UserID).Where(m => m.Focused == BloggerID).ToList(); //判断是否关注此人

            if (focuses.Count() == 0)                                                                                             //没有关注
            {
                ViewData["guanzhu"] = "关注";
            }
            else//关注了
            {
                ViewData["guanzhu"] = "取消关注";
            }
            ViewData["likescount"]   = likescount;
            ViewData["BloggerImage"] = user.UserImage;
            ViewData["BloggerID"]    = blog.BloggerID;
            ViewData["userName"]     = user.UserName;
            ViewData["fancount"]     = fancount;
            ViewData["focuscount"]   = focuscount;
            ViewBag.comments         = comments;
            return(View(blog));
        }
Beispiel #10
0
        public void UserAccountModelToEntityConfigurationIsValid()
        {
            var model = new Models.UserAccount();

            model.Accounts = new List <Models.ExternalAccount>
            {
                new Models.ExternalAccount
                {
                    UserAccount = model
                }
            };

            var mappedEntity = model.ToEntity();
            var mappedModel  = mappedEntity.ToModel();

            Assert.NotNull(mappedModel);
            Assert.NotNull(mappedEntity);
            UserAccountMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid();
        }
        public ActionResult Verify(Models.UserAccount acc)
        {
            using (var dataContext = new UsersEntities())
            {
                var _passWord           = PasswordEncryption.textToEncrypt(acc.Password);
                Models.UserAccount user = dataContext.UserAccounts.Where(x => x.Email == acc.Email && x.Password == _passWord).SingleOrDefault();

                if (user == null)
                {
                    ViewBag.ErrorMessage = "Invalid Email or Password";
                    return(View("Login", user));
                }
                else
                {
                    Session["userID"]   = user.UserID;
                    Session["userName"] = user.UserName;
                    Session["Email"]    = user.Email;
                    return(RedirectToAction("Welcome", "Account"));
                }
            }
        }
 public static void UpdateEntity(
     this Models.UserAccount model, UserAccount entity)
 {
     Mapper.Map(model, entity);
 }
 public static UserAccount ToEntity(this Models.UserAccount model)
 {
     return(model == null ? null : Mapper
            .Map <UserAccount>(model));
 }