Ejemplo n.º 1
0
        public void GetActorShouldReturnActor()
        {
            DbContextOptions <UltimateMoviesDbContext> options = new DbContextOptionsBuilder <UltimateMoviesDbContext>()
                                                                 .UseInMemoryDatabase(databaseName: "Actors_GetActor_Database")
                                                                 .Options;
            UltimateMoviesDbContext db = new UltimateMoviesDbContext(options);

            IActorsService actorsService = new ActorsService(db);

            db.Actors.Add(new Actor
            {
                Name = "Mark Hamill"
            });

            db.SaveChanges();

            Actor actor = actorsService.GetActor(db.Actors.Last().Id);

            Assert.Equal("Mark Hamill", actor.Name);
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["director"] == null && Request.QueryString["actor"] == null)
            {
                Response.Redirect("./Celebrity.aspx?director=1");
            }
            int id = Request.QueryString["director"] != null?int.Parse(Request.QueryString["director"]) : int.Parse(Request.QueryString["actor"]);

            StringBuilder sb = new StringBuilder();

            if (Request.QueryString["director"] != null)
            {
                dir   = dirService.GetDirectory(id);
                actor = null;
                List <DirService.classicFilm> classicFilms = new List <DirService.classicFilm>();
                classicFilms = dirService.GetClassicFilms(id);
                if (classicFilms != null)
                {
                    foreach (var i in classicFilms)
                    {
                        if (classicFilms.IndexOf(i) >= 3)
                        {
                            break;
                        }
                        sb.Append("<div class='banner-body-classic-item' onclick=\"window.open('./Film.aspx?id=" + i.filmId + "','_self')\">");
                        sb.Append("<img src='" + i.filmPic + "' />");
                        sb.Append("<div class='banner-body-classic-item-label'>");
                        sb.Append("<span>" + i.filmName + "</span>");
                        sb.Append("</div></div>");
                    }
                }
                ClassicList = sb.ToString();
                int  count = 0;
                bool flag  = false;
                sb.Clear();
                sb.Append("<div class='container-module-body-info-row'>");
                for (int i = 0; i < 7; i++)
                {
                    if (count != 0 && count % 2 == 0 && flag)
                    {
                        flag = false;
                        sb.Append("</div>");
                        sb.Append("<div class='container-module-body-info-row'>");
                    }
                    switch (i)
                    {
                    case 0:
                        if (dir.dirAlias != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>别&emsp;&emsp;名</span>");
                            sb.Append("<div><span>" + dir.dirAlias + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 1:
                        if (dir.dirGender != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>性&emsp;&emsp;别</span>");
                            sb.Append("<div><span>" + dir.dirGender + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 2:
                        if (dir.dirCountry != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>国&emsp;&emsp;籍</span>");
                            sb.Append("<div><span>" + dir.dirCountry + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 3:
                        if (dir.dirBirthday != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>出生日期</span>");
                            sb.Append("<div><span>" + dir.dirBirthday + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 4:
                        if (dir.dirPlaceOfBirth != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>出生地点</span>");
                            sb.Append("<div><span>" + dir.dirPlaceOfBirth + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 5:
                        if (dir.dirIdentity != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>身&emsp;&emsp;份</span>");
                            sb.Append("<div><span>" + dir.dirIdentity + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 6:
                        if (dir.dirHeight != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>身&emsp;&emsp;高</span>");
                            sb.Append("<div><span>" + dir.dirHeight + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;
                    }
                }
                sb.Append("</dir>");
                InfoList = sb.ToString();
                sb.Clear();
                string current = classicFilms != null ? classicFilms[0].filmReleaseDate.Substring(0, 4) : "";
                sb.Append("<li class='layui-timeline-item'>");
                sb.Append("<i class='layui-icon layui-timeline-axis layui-icon-play'></i>");
                sb.Append("<div class='layui-timeline-content layui-text'>");
                sb.Append("<h3 class='layui-timeline-title'>" + current + "年</h3>");
                sb.Append("<div class='timeline-item-main'>");
                if (classicFilms != null)
                {
                    foreach (var i in classicFilms)
                    {
                        string currentDate = i.filmReleaseDate.Substring(0, 4);
                        if (currentDate != current)
                        {
                            current = currentDate;
                            sb.Append("</div></div></li>");
                            sb.Append("<li class='layui-timeline-item'>");
                            sb.Append("<i class='layui-icon layui-timeline-axis layui-icon-play'></i>");
                            sb.Append("<div class='layui-timeline-content layui-text'>");
                            sb.Append("<h3 class='layui-timeline-title'>" + current + "年</h3>");
                            sb.Append("<div class='timeline-item-main'>");
                        }
                        sb.Append("<div class='timeline-item-main-item' onclick=\"window.open('./Film.aspx?id=" + i.filmId + "','_self')\">");
                        sb.Append("<img src='" + i.filmPic + "'/>");
                        sb.Append("<p class='timeline-item-main-item-title'>" + i.filmName + "</p>");
                        sb.Append("<p>导演</p>");
                        sb.Append("</div>");
                    }
                }
                sb.Append("</div></div></li>");
                FilmsList = sb.ToString();
            }
            else
            {
                actor = actorsService.GetActor(id);
                dir   = null;
                List <ActorsService.classicFilm> classicFilms = new List <ActorsService.classicFilm>();
                classicFilms = actorsService.GetClassicFilms(id);
                if (classicFilms != null)
                {
                    foreach (var i in classicFilms)
                    {
                        if (classicFilms.IndexOf(i) >= 3)
                        {
                            break;
                        }
                        sb.Append("<div class='banner-body-classic-item' onclick=\"window.open('./Film.aspx?id=" + i.filmId + "','_self')\">");
                        sb.Append("<img src='" + i.filmPic + "' />");
                        sb.Append("<div class='banner-body-classic-item-label'>");
                        sb.Append("<span>" + i.filmName + "</span>");
                        sb.Append("</div></div>");
                    }
                }
                ClassicList = sb.ToString();
                int  count = 0;
                bool flag  = false;
                sb.Clear();
                sb.Append("<div class='container-module-body-info-row'>");
                for (int i = 0; i < 9; i++)
                {
                    if (count != 0 && count % 2 == 0 && flag)
                    {
                        flag = false;
                        sb.Append("</div>");
                        sb.Append("<div class='container-module-body-info-row'>");
                    }
                    switch (i)
                    {
                    case 0:
                        if (actor.actorAlias != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>别&emsp;&emsp;名</span>");
                            sb.Append("<div><span>" + actor.actorAlias + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 1:
                        if (actor.actorGender != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>性&emsp;&emsp;别</span>");
                            sb.Append("<div><span>" + actor.actorGender + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 2:
                        if (actor.actorCountry != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>国&emsp;&emsp;籍</span>");
                            sb.Append("<div><span>" + actor.actorCountry + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 3:
                        if (actor.actorBirthday != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>出生日期</span>");
                            sb.Append("<div><span>" + actor.actorBirthday + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 4:
                        if (actor.actorPlaceOfBirth != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>出生地点</span>");
                            sb.Append("<div><span>" + actor.actorPlaceOfBirth + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 5:
                        if (actor.actorIdentity != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>身&emsp;&emsp;份</span>");
                            sb.Append("<div><span>" + actor.actorIdentity + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 6:
                        if (actor.actorHeight != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>身&emsp;&emsp;高</span>");
                            sb.Append("<div><span>" + actor.actorHeight + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 7:
                        if (actor.actorAgency != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>经纪公司</span>");
                            sb.Append("<div><span>" + actor.actorAgency + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;

                    case 8:
                        if (actor.actorGraduatedSchool != null)
                        {
                            sb.Append("<div class='container-module-body-info-item'>");
                            sb.Append("<span class='container-module-body-info-title'>毕业学校</span>");
                            sb.Append("<div><span>" + actor.actorGraduatedSchool + "</span></div></div>");
                            count++;
                            flag = true;
                        }
                        break;
                    }
                }
                sb.Append("</dir>");
                InfoList = sb.ToString();
                sb.Clear();
                string current = classicFilms != null?classicFilms[0].filmReleaseDate.Substring(0, 4):"";
                sb.Append("<li class='layui-timeline-item'>");
                sb.Append("<i class='layui-icon layui-timeline-axis layui-icon-play'></i>");
                sb.Append("<div class='layui-timeline-content layui-text'>");
                sb.Append("<h3 class='layui-timeline-title'>" + current + "年</h3>");
                sb.Append("<div class='timeline-item-main'>");
                if (classicFilms != null)
                {
                    foreach (var i in classicFilms)
                    {
                        string currentDate = i.filmReleaseDate.Substring(0, 4);
                        if (currentDate != current)
                        {
                            current = currentDate;
                            sb.Append("</div></div></li>");
                            sb.Append("<li class='layui-timeline-item'>");
                            sb.Append("<i class='layui-icon layui-timeline-axis layui-icon-play'></i>");
                            sb.Append("<div class='layui-timeline-content layui-text'>");
                            sb.Append("<h3 class='layui-timeline-title'>" + current + "年</h3>");
                            sb.Append("<div class='timeline-item-main'>");
                        }
                        sb.Append("<div class='timeline-item-main-item' onclick=\"window.open('./Film.aspx?id=" + i.filmId + "','_self')\">");
                        sb.Append("<img src='" + i.filmPic + "'/>");
                        sb.Append("<p class='timeline-item-main-item-title'>" + i.filmName + "</p>");
                        sb.Append("<p>演员</p>");
                        sb.Append("</div>");
                    }
                }
                sb.Append("</div></div></li>");
                FilmsList = sb.ToString();
            }
        }