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
        static void Main(string[] args)
        {
            var db = new ImdbContext();

            db.Database.EnsureCreated();

            var root   = new MenuItem("Hlavní menu");
            var manage = new Configuration();
            var movie  = new MovieManage();
            var actor  = new ActorManage();

            var current = root;

            #region Movie
            var moviesMain       = new MenuItem("Filmy");
            var addMovie         = new MenuItem("Přidat film");
            var addMovieOmdb     = new MenuItem("Přidat film z OMDb");
            var listMovie        = new MenuItem("Seznam filmů");
            var informationMovie = new MenuItem("Informace o filmu");
            var openLink         = new MenuItem("Otevřít odkaz");

            var addGenre  = new MenuItem("Přidat žánr");
            var moreNames = new MenuItem("Přidat více jmen");


            var manageMovie       = new MenuItem("Spravovat film");
            var changeName        = new MenuItem("Změnit název");
            var changeDescription = new MenuItem("Změnit popis");
            var changeRating      = new MenuItem("Změnit hodnocení");
            var changeLink        = new MenuItem("Změnit odkaz");
            var deleteMovie       = new MenuItem("Smazat film");


            root.Items.Add(moviesMain);
            moviesMain.Items.Add(addMovie);
            moviesMain.Items.Add(addMovieOmdb);
            moviesMain.Items.Add(listMovie);
            moviesMain.Items.Add(informationMovie);
            moviesMain.Items.Add(openLink);
            moviesMain.Items.Add(addGenre);
            moviesMain.Items.Add(moreNames);



            moviesMain.Items.Add(manageMovie);
            manageMovie.Items.Add(changeName);
            manageMovie.Items.Add(changeDescription);
            manageMovie.Items.Add(changeRating);
            manageMovie.Items.Add(changeLink);
            manageMovie.Items.Add(deleteMovie);

            #endregion

            #region Actor
            var actorMain       = new MenuItem("Herci");
            var addActor        = new MenuItem("Přidat herce");
            var listActors      = new MenuItem("Seznam Herců");
            var assignActor     = new MenuItem("Přiřadit herce k filmu");
            var removeActor     = new MenuItem("Odebrat herce z filmu");
            var deleteActor     = new MenuItem("Smazat herce");
            var listActorMovies = new MenuItem("listActorMovies");
            root.Items.Add(actorMain);
            actorMain.Items.Add(addActor);
            actorMain.Items.Add(listActors);
            actorMain.Items.Add(assignActor);
            actorMain.Items.Add(removeActor);
            actorMain.Items.Add(listActorMovies);
            actorMain.Items.Add(deleteActor);

            #endregion

            var userMain = new MenuItem("Uživatelé");

            while (true)
            {
                current.Draw();
                var key = Console.ReadKey(true);
                //int i = 0;
                //int b=i++; // int b=i; i=i+1;
                //int c=++i; // i=i+1; int c=i;
                switch (key.Key)
                {
                    #region EventHandle



                case ConsoleKey.UpArrow:
                    if (current.SelectedItemIndex - 1 >= 0)
                    {
                        current.SelectedItemIndex--;
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (current.SelectedItemIndex + 1 < current.Items.Count)
                    {
                        current.SelectedItemIndex++;
                    }
                    break;

                case ConsoleKey.Enter:
                    var selected = current.Items[current.SelectedItemIndex];
                    #endregion

                    #region Movie
                    if (selected == addMovie)
                    {
                        movie.AddMovie();
                        Console.ReadLine();
                    }

                    else if (selected == listMovie)
                    {
                        movie.listMovie();
                        Console.ReadLine();
                    }
                    else if (selected == informationMovie)
                    {
                        movie.informationMovie();
                        Console.ReadLine();
                    }
                    else if (selected == openLink)
                    {
                        movie.openLink();
                        Console.ReadLine();
                    }
                    else if (selected == deleteMovie)
                    {
                        manage.deleteMovie();
                        Console.ReadLine();
                    }
                    else if (selected == changeName)
                    {
                        manage.changeMovieName();
                        Console.ReadLine();
                    }
                    else if (selected == moreNames)
                    {
                        movie.addMoreNames();
                        Console.ReadLine();
                    }
                    else if (selected == addMovieOmdb)
                    {
                        movie.omdb();
                        Console.ReadLine();
                    }
                    else if (selected == addGenre)
                    {
                        movie.addGenres();
                        Console.ReadLine();
                    }
                    else if (selected == changeDescription)
                    {
                        manage.changeDescription();
                        Console.ReadLine();
                    }
                    else if (selected == changeLink)
                    {
                        manage.changeLink();
                        Console.ReadLine();
                    }
                    else if (selected == changeRating)
                    {
                        manage.changeRating();
                        Console.ReadLine();
                    }
                    #endregion

                    #region Actor
                    else if (selected == addActor)
                    {
                        actor.AddActor();
                        Console.ReadLine();
                    }
                    else if (selected == listActors)
                    {
                        actor.listActors();
                        Console.ReadLine();
                    }
                    else if (selected == assignActor)
                    {
                        actor.AssignActor();
                        Console.ReadLine();
                    }
                    else if (selected == removeActor)
                    {
                        actor.removeActor();
                        Console.ReadLine();
                    }
                    else if (selected == deleteActor)
                    {
                        actor.deleteActor();
                        Console.ReadLine();
                    }
                    else if (selected == listActorMovies)
                    {
                        actor.listActorMovies();
                        Console.ReadLine();
                    }
                    #endregion
                    else
                    {
                        current = selected;
                    }
                    break;
                    #region EvenHandle



                case ConsoleKey.Escape:
                case ConsoleKey.Backspace:
                    current = root;
                    break;
                    #endregion
                }
            }
        }
Ejemplo n.º 6
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));
        }