Ejemplo n.º 1
0
        public ActionResult Modify(int ID)
        {
            var _users = new UserManage().FindList();
            List <SelectListItem> _userlistItems = new List <SelectListItem>(_users.Count());

            foreach (var _user in _users)
            {
                _userlistItems.Add(new SelectListItem()
                {
                    Text = _user.Username, Value = _user.ID.ToString()
                });
            }
            ViewBag.Users = _userlistItems;
            var _movies = new MovieManage().FindList();
            List <SelectListItem> _movielistItems = new List <SelectListItem>(_movies.Count());

            foreach (var _movie in _movies)
            {
                _movielistItems.Add(new SelectListItem()
                {
                    Text = _movie.MovieName, Value = _movie.ID.ToString()
                });
            }
            ViewBag.Movies = _movielistItems;
            var _Article = articleManage.Find(ID);

            return(View(_Article));
        }
Ejemplo n.º 2
0
        public ActionResult ArticleSubmit()
        {
            var _movies = new MovieManage().FindList();
            List <SelectListItem> _movielistItems = new List <SelectListItem>(_movies.Count());

            foreach (var _movie in _movies)
            {
                _movielistItems.Add(new SelectListItem()
                {
                    Text = _movie.MovieName, Value = _movie.ID.ToString()
                });
            }
            ViewBag.Movies = _movielistItems;
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult Modify(int ID)
        {
            var _users = new UserManage().FindList();
            List <SelectListItem> _userlistItems = new List <SelectListItem>(_users.Count());

            foreach (var _user in _users)
            {
                _userlistItems.Add(new SelectListItem()
                {
                    Text = _user.Username, Value = _user.ID.ToString()
                });
            }
            ViewBag.Users = _userlistItems;
            var _movies = new MovieManage().FindList();
            List <SelectListItem> _movielistItems = new List <SelectListItem>(_movies.Count());

            foreach (var _movie in _movies)
            {
                _movielistItems.Add(new SelectListItem()
                {
                    Text = _movie.MovieName, Value = _movie.ID.ToString()
                });
            }
            ViewBag.Movies = _movielistItems;
            var comment = commentManage.Find(ID);
            var _likes  = new LikeManage().FindList();
            int like    = 0;

            foreach (var _like in _likes)
            {
                if (ID == _like.MovieCommentID)
                {
                    like++;
                }
            }
            comment.Likes = like;
            return(PartialView(comment));
        }
Ejemplo n.º 4
0
        public ActionResult Add(AddArticelViewModel articleViewModel, HttpPostedFileBase banner)
        {
            var MaxId     = articleManage.ArticleId(p => p.ID);
            var articleID = MaxId + 1;

            if (banner != null)
            {
                var bannerName = Path.Combine(Request.MapPath("/ArticleImg"), articleID + ".jpg");
                if (System.IO.File.Exists(bannerName))
                {
                    System.IO.File.Delete(bannerName);
                }
                banner.SaveAs(bannerName);
            }
            if (ModelState.IsValid)
            {
                Article _article = new Article();
                _article.UserID      = articleViewModel.UserID;
                _article.MovieID     = articleViewModel.MovieID;
                _article.Releasetime = articleViewModel.Releasetime;
                _article.Title       = articleViewModel.Title;
                _article.Content     = articleViewModel.Content;
                _article.Auditstatus = Article.Status.待审核;
                var _resp = articleManage.Add(_article);
                if (_resp.Code == 1)
                {
                    return(View("Prompt", new Prompt()
                    {
                        Title = "添加文章成功",
                        Message = "您成功的添加了当前文章",
                        Buttons = new List <string>()
                        {
                            "<a href=\"" + Url.Action("Index", "Article") + "\" class=\"btn btn-default\">文章管理</a>",
                            "<a href=\"" + Url.Action("Add", "Article") + "\" class=\"btn btn-default\">继续添加</a>"
                        }
                    }
                                ));
                }
                else
                {
                    ModelState.AddModelError("", _resp.Message);
                }
            }
            else
            {
                return(View(articleViewModel));
            }
            var _users = new UserManage().FindList();
            List <SelectListItem> _userlistItems = new List <SelectListItem>(_users.Count());

            foreach (var _user in _users)
            {
                _userlistItems.Add(new SelectListItem()
                {
                    Text = _user.Username, Value = _user.ID.ToString()
                });
            }
            ViewBag.Users = _userlistItems;
            var _movies = new MovieManage().FindList();
            List <SelectListItem> _movielistItems = new List <SelectListItem>(_movies.Count());

            foreach (var _movie in _movies)
            {
                _movielistItems.Add(new SelectListItem()
                {
                    Text = _movie.MovieName, Value = _movie.ID.ToString()
                });
            }
            ViewBag.Movies = _movielistItems;
            return(View(articleViewModel));
        }
Ejemplo n.º 5
0
        public ActionResult Add(AddCommentViewModel commentViewModel)
        {
            if (commentManage.HasUserComment(commentViewModel.UserID, commentViewModel.MovieID))
            {
                return(View("Prompt", new Prompt()
                {
                    Title = "添加失败",
                    Message = "当前用户已对当前电影评论\n注意!每个用户对每个电影只能评论一次!",
                    Buttons = new List <string>()
                    {
                        "<a href=\"" + Url.Action("Index", "Comment") + "\" class=\"btn btn-default\">评论管理</a>",
                        "<a href=\"" + Url.Action("Add", "Comment") + "\" class=\"btn btn-default\">重新添加</a>"
                    }
                }
                            ));
            }
            if (ModelState.IsValid)
            {
                MovieComment _comment = new MovieComment();
                _comment.UserID      = commentViewModel.UserID;
                _comment.MovieID     = commentViewModel.MovieID;
                _comment.CommentTime = commentViewModel.CommentTime;
                _comment.Content     = commentViewModel.Content;
                _comment.Score       = commentViewModel.Score;
                var _user = userManage.Find(commentViewModel.UserID);
                if (_user.Userstatus == DAL.Models.User.UserStatus.未启用)
                {
                    return(View("Prompt", new Prompt()
                    {
                        Title = "添加评论失败",
                        Message = "当前用户已被冻结,无法评论!请先启用当前用户",
                        Buttons = new List <string>()
                        {
                            "<a href=\"" + Url.Action("Index", "Comment") + "\" class=\"btn btn-default\">评论管理</a>",
                            "<a href=\"" + Url.Action("Add", "Comment") + "\" class=\"btn btn-default\">重新添加</a>"
                        }
                    }
                                ));
                }
                var _resp = commentManage.Add(_comment);
                if (_resp.Code == 1)
                {
                    return(View("Prompt", new Prompt()
                    {
                        Title = "添加评论成功",
                        Message = "您已为此用户添加了评论",
                        Buttons = new List <string>()
                        {
                            "<a href=\"" + Url.Action("Index", "Comment") + "\" class=\"btn btn-default\">评论管理</a>",
                            "<a href=\"" + Url.Action("Add", "Comment") + "\" class=\"btn btn-default\">继续添加</a>"
                        }
                    }
                                ));
                }
                else
                {
                    ModelState.AddModelError("", _resp.Message);
                }
            }
            else
            {
                return(View(commentViewModel));
            }
            var _users = new UserManage().FindList();
            List <SelectListItem> _userlistItems = new List <SelectListItem>(_users.Count());

            foreach (var _user in _users)
            {
                _userlistItems.Add(new SelectListItem()
                {
                    Text = _user.Username, Value = _user.ID.ToString()
                });
            }
            ViewBag.Users = _userlistItems;
            var _movies = new MovieManage().FindList();
            List <SelectListItem> _movielistItems = new List <SelectListItem>(_movies.Count());

            foreach (var _movie in _movies)
            {
                _movielistItems.Add(new SelectListItem()
                {
                    Text = _movie.MovieName, Value = _movie.ID.ToString()
                });
            }
            ViewBag.Movies = _movielistItems;
            return(View(commentViewModel));
        }