public void Create(string name, string address)
        {
            var studio = new Studio
            {
                Name = name,
                Address = address
            };

            this.data.Add(studio);
            this.data.SaveChanges();
        }
        public ActionResult Create(Studio studio)
        {
            if (ModelState.IsValid)
            {
                db.Studios.Add(studio);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(studio);
        }
 public void Verify_Add_Should_AddTheEntityToTheContext()
 {
     // Arrange
     Mock<IDbSet<Studio>> mockSetStudios;
     var mockContext = StudiosMockingSetup.DoMockingSetupForContext(false, out mockSetStudios);
     var repository = new StudiosRepository(mockContext.Object);
     var studios = new Studio { Active = true, CustomKey = "SALVATORE-RAA", };
     // Act
     repository.Add(studios);
     // Assert
     mockSetStudios.Verify(x => x.Add(studios), Times.Once);
 }
        public DisassemblyDocument( Studio studio )
            : this()
        {
            Debug.Assert( studio != null );
            if( studio == null )
                throw new ArgumentNullException( "studio" );
            _studio = studio;

            this.Icon = IconUtilities.ConvertToIcon( Properties.Resources.DisassemblyIcon );

            _statementIcon = codeEditorControl.GutterIcons.Images.Add( Properties.Resources.StatementIcon, Color.Transparent );
            _statementCallIcon = codeEditorControl.GutterIcons.Images.Add( Properties.Resources.StatementCallIcon, Color.Transparent );
            _statementDeadIcon = codeEditorControl.GutterIcons.Images.Add( Properties.Resources.StatementDeadIcon, Color.Transparent );

            _statements = new Dictionary<int, Statement>();

            this.PopulateMethods();

            //CodeEditorSyntaxLoader.SetSyntax( _editor, SyntaxLanguage.Text );
        }
Exemple #5
0
        public CpuPane( Studio studio )
            : this()
        {
            Debug.Assert( studio != null );
            if( studio == null )
                throw new ArgumentNullException( "studio" );
            _studio = studio;

            this.Icon = IconUtilities.ConvertToIcon( Properties.Resources.RegistersIcon );

            _cpu = _studio.Debugger.Host.CurrentInstance.Cpu;
            _core0 = _cpu.Cores[ 0 ];

            _studio.GlobalRefreshRequested += new EventHandler( StudioGlobalRefreshRequested );

            this.generalRegistersLabel_SizeChanged( this, EventArgs.Empty );

            _useFriendlyLabels = true;
            this.friendlyCheckbox.Checked = _useFriendlyLabels;

            this.UpdateValues();
        }
Exemple #6
0
        private async void Row_MouseDoubleClickAsync(object sender, MouseButtonEventArgs e)
        {
            cellValue = GetSelectedCellValue();
            string path = $"api/{currentEntity}/{cellValue}";


            if (currentView == "FilmCrewView")
            {
                LoadWindow(2);
                FilmCrew            obj      = new FilmCrew();
                HttpResponseMessage response = await client.GetAsync(path);

                if (response.IsSuccessStatusCode)
                {
                    obj = await response.Content.ReadAsAsync <FilmCrew>();
                }
                LoadCrewBoxesAsync();
                addField1.Text = obj.Firstname;
                addField2.Text = obj.Name;
                addField3.Text = obj.Age.ToString();
            }
            if (currentView == "MovieView")
            {
                LoadWindow(0);
                Movie obj = new Movie();
                HttpResponseMessage response = await client.GetAsync(path);

                if (response.IsSuccessStatusCode)
                {
                    obj = await response.Content.ReadAsAsync <Movie>();
                }
                LoadMovieBoxesAsync();
                addField1.Text = obj.Title;
                addField2.Text = obj.ProductionYear.ToString();
                addField3.Text = obj.Budget.ToString();;
                addField4.Text = obj.Genre;
            }
            if (currentView == "ContractView")
            {
                LoadWindow(1);
                Contract            obj      = new Contract();
                HttpResponseMessage response = await client.GetAsync(path);

                if (response.IsSuccessStatusCode)
                {
                    obj = await response.Content.ReadAsAsync <Contract>();
                }
                LoadContractBoxesAsync();
                addField1.Text = obj.Duration.ToString();
                addField2.Text = obj.Salary.ToString();
            }
            if (currentView == "Studio")
            {
                LoadWindow(4);
                Studio obj = new Studio();
                HttpResponseMessage response = await client.GetAsync(path);

                if (response.IsSuccessStatusCode)
                {
                    obj = await response.Content.ReadAsAsync <Studio>();
                }
                LoadStudioBoxes();
                addField1.Text = obj.Name;
                addField2.Text = obj.YearOfEstablishment.ToString();
            }
            if (currentView == "Position")
            {
                LoadWindow(3);
                Position            obj      = new Position();
                HttpResponseMessage response = await client.GetAsync(path);

                if (response.IsSuccessStatusCode)
                {
                    obj = await response.Content.ReadAsAsync <Position>();
                }
                LoadPositionBoxes();
                addField1.Text = obj.PositionName;
            }
        }
Exemple #7
0
 public JsonResult AjaxEdit(Studio studio)
 {
     db.Entry(studio).State = EntityState.Modified;
     db.SaveChanges();
     return(Json(studio));
 }
Exemple #8
0
        public static void SeedDatabase(DataContext context)
        {
            if (context.Database.GetMigrations().Count() > 0 &&
                context.Database.GetPendingMigrations().Count() == 0
                & context.Movies.Count() == 0)
            {
                var s1 = new Studio
                {
                    Name  = "Moonlight Entertainment",
                    City  = "San Jose",
                    State = "CA"
                };
                var s2 = new Studio
                {
                    Name  = "Paramount",
                    City  = "Chicago",
                    State = "IL"
                };
                var s3 = new Studio
                {
                    Name  = "MGM",
                    City  = "New York",
                    State = "NY"
                };

                context.Movies.AddRange(
                    new Movie
                {
                    Name        = "Titanic",
                    Description = "A 17-year-old aristocrat falls in love with a kind but poor artist aboard the luxurious, ill-fated R.M.S. Titanic.",
                    Category    = "Drama",
                    Price       = 75,
                    Studio      = s1,
                    Ratings     = new List <Rating> {
                        new Rating {
                            Stars = 4
                        }, new Rating {
                            Stars = 3
                        }
                    }
                },
                    new Movie
                {
                    Name        = "The Godfather",
                    Description = "The aging patriarch of an organized crime dynasty transfers control of his clandestine empire to his reluctant son",
                    Category    = "Drama",
                    Price       = 48.95m,
                    Studio      = s1,
                    Ratings     = new List <Rating> {
                        new Rating {
                            Stars = 2
                        }, new Rating {
                            Stars = 5
                        }
                    }
                },
                    new Movie
                {
                    Name        = "Team America",
                    Description = "Broadway actor Gary Johnston is recruited by the elite counter-terrorism organization",
                    Category    = "Comedy",
                    Price       = 19.50m,
                    Studio      = s2,
                    Ratings     = new List <Rating> {
                        new Rating {
                            Stars = 1
                        }, new Rating {
                            Stars = 3
                        }
                    }
                },
                    new Movie
                {
                    Name        = "Wedding Crashers",
                    Description = "Committed womanizers sneak into weddings to take advantage of the romantic tinge in the air",
                    Category    = "Comedy",
                    Price       = 34.95m,
                    Studio      = s2,
                    Ratings     = new List <Rating> {
                        new Rating {
                            Stars = 3
                        }
                    }
                },
                    new Movie
                {
                    Name        = "Superbad",
                    Description = "Two co-dependent high school seniors are forced to deal with separation anxiety after their plan to stage a booze-soaked party goes awry",
                    Category    = "Comedy",
                    Price       = 70,
                    Studio      = s2,
                    Ratings     = new List <Rating> {
                        new Rating {
                            Stars = 1
                        },
                        new Rating {
                            Stars = 4
                        }, new Rating {
                            Stars = 3
                        }
                    }
                },
                    new Movie
                {
                    Name        = "Bridget Jones's Diary",
                    Description = "A British woman is determined to improve herself while she looks for love in a year in which she keeps a personal diary.",
                    Category    = "Romance",
                    Price       = 16,
                    Studio      = s3,
                    Ratings     = new List <Rating> {
                        new Rating {
                            Stars = 5
                        },
                        new Rating {
                            Stars = 4
                        }
                    }
                },
                    new Movie
                {
                    Name        = "Love Actually",
                    Description = "Eight very different couples deal with their love lives",
                    Category    = "Romance",
                    Price       = 29.95m,
                    Studio      = s3,
                    Ratings     = new List <Rating> {
                        new Rating {
                            Stars = 3
                        }
                    }
                },
                    new Movie
                {
                    Name        = "The Way We Were",
                    Description = "Two desperate people have a wonderful romance, but their political views and convictions drive them apart.",
                    Category    = "Romance",
                    Price       = 75,
                    Studio      = s3
                },
                    new Movie
                {
                    Name        = "Ghost",
                    Description = "After a young man is murdered, his spirit stays behind to warn his lover of impending danger, with the help of a reluctant psychic.",
                    Category    = "Romance",
                    Price       = 10,
                    Studio      = s3
                });
                context.SaveChanges();
            }
        }
Exemple #9
0
 public override int GetHashCode()
 {
     return(Genre.GetHashCode() ^ Studio.GetHashCode() ^ Director.GetHashCode() ^ Actor1.GetHashCode() ^ Actor2.GetHashCode() ^ Profit.GetHashCode());
 }
Exemple #10
0
 public JsonResult AjaxCreate(Studio studio)
 {
     db.Studios.Add(studio);
     db.SaveChanges();
     return(Json(studio));
 }
 public void Add(Studio studio)
 {
     _dbContext.Add(studio);
 }
 public async Task AddAndSave(Studio studio)
 {
     _studioRepo.Add(studio);
     await _studioRepo.Save();
 }
Exemple #13
0
 public ActionResult Delete(int id, Studio studio)
 {
     _studioService.Delete(studio);
     return(RedirectToAction(nameof(Index)));
 }
Exemple #14
0
 private void ShowSettings(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     Studio.ShowManualItemSettings(Version);
 }
 public async Task UpdateStudio(Studio studio)
 {
     _context.Studios.Update(studio);
     await _context.SaveChangesAsync();
 }
Exemple #16
0
 public override int GetHashCode()
 {
     return(Name.GetHashCode() ^ Genre.GetHashCode() ^ Studio.GetHashCode() ^ Actor1.GetHashCode() ^ Actor2.GetHashCode());
 }
Exemple #17
0
 private void BtnAddPage_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     Studio.AddPage(Version, true);
 }
 public void Delete(Studio studio)
 {
     this.data.Delete(studio);
     this.data.SaveChanges();
 }
 public ActionResult Edit(Studio studio)
 {
     if (ModelState.IsValid)
     {
         db.Entry(studio).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(studio);
 }
Exemple #20
0
 public void AddStudio(Studio studio)
 {
     adonetStudioService.AddStudio(studio);
 }
Exemple #21
0
 private void BtnAddSection_Click(object sender, RoutedEventArgs e)
 {
     Studio.AddSection(Page, true);
 }
 public void Update(Studio studio)
 {
     _dbContext.Update(studio);
 }
Exemple #23
0
 private void BtnSettings_MouseUp(object sender, MouseButtonEventArgs e)
 {
     Studio.ShowManualItemSettings(Page);
 }
 public async Task UpdateAndSave(Studio studio)
 {
     _studioRepo.Update(studio);
     await _studioRepo.Save();
 }
Exemple #25
0
 private void BtnRemove_MouseUp(object sender, MouseButtonEventArgs e)
 {
     Studio.RemoveManualItem(Page, true);
 }
Exemple #26
0
 public Studio Update(Studio Studio)
 {
     _context.Entry(Studio).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     _context.SaveChanges();
     return(Studio);
 }
Exemple #27
0
 public void UpdateStudio(Studio studio)
 {
     this.studioRepository.Update(studio);
     this.unitOfWork.Commit();
 }
Exemple #28
0
        public PartialViewResult StudioEdit(int id)
        {
            Studio studio = db.Studios.Find(id);

            return(PartialView(studio));
        }
        public ActionResult New()
        {
            Studio studio = new Studio();

            return(View(studio));
        }
Exemple #30
0
 public Task <bool> AddStudio(ShowMetadata metadata, Studio studio) => throw new NotSupportedException();
 public Task <bool> AddStudio(ShowMetadata metadata, Studio studio) =>
 _dbConnection.ExecuteAsync(
     "INSERT INTO Studio (Name, ShowMetadataId) VALUES (@Name, @MetadataId)",
     new { studio.Name, MetadataId = metadata.Id }).Map(result => result > 0);
Exemple #32
0
 private StudioViewModel StudioToViewModel(Studio studio)
 {
     return(Mapper.Map <StudioViewModel>(studio));
 }
 public ManageStudioForm(Studio studio) : this()
 {
     _scopedStudio = studio;
 }
Exemple #34
0
        private async void updateItemButton_ClickAsync(object sender, RoutedEventArgs e)
        {
            try
            {
                int cellValueInt = Convert.ToInt32(cellValue);

                if (entityPickerCombo.Text == myEntities[0])
                {
                    Movie obj = new Movie
                    {
                        MovieId        = cellValueInt,
                        Title          = addField1.Text,
                        ProductionYear = Convert.ToInt32(addField2.Text),
                        Budget         = Convert.ToInt32(addField3.Text),
                        Genre          = addField4.Text,
                        StudioId       = Convert.ToInt32(addCombo1.Text.Split('.')[0])
                    };
                    await UpdateItemAsync(obj, "movies", cellValueInt);
                }
                if (entityPickerCombo.Text == myEntities[1])
                {
                    Contract obj = new Contract
                    {
                        ContractId   = cellValueInt,
                        Duration     = Convert.ToInt32(addField1.Text),
                        Salary       = Convert.ToInt32(addField2.Text),
                        CrewMemberId = Convert.ToInt32(addCombo1.Text.Split('.')[0]),  ///
                        MovieId      = Convert.ToInt32(addCombo2.Text.Split('.')[0])
                    };
                    await UpdateItemAsync(obj, "contracts", cellValueInt);
                }
                if (entityPickerCombo.Text == myEntities[2])
                {
                    FilmCrew obj = new FilmCrew
                    {
                        CrewMemberId = cellValueInt,
                        Name         = addField1.Text,
                        Firstname    = addField2.Text,
                        Age          = Convert.ToInt32(addField3.Text),
                        PositionId   = Convert.ToInt32(addCombo1.Text.Split('.')[0])
                    };
                    await UpdateItemAsync(obj, "filmcrews", cellValueInt);
                }
                if (entityPickerCombo.Text == myEntities[3])
                {
                    Position obj = new Position
                    {
                        PositionId   = cellValueInt,
                        PositionName = addField1.Text
                    };
                    await UpdateItemAsync(obj, "positions", cellValueInt);
                }
                if (entityPickerCombo.Text == myEntities[4])
                {
                    Studio obj = new Studio
                    {
                        StudioId            = cellValueInt,
                        Name                = addField1.Text,
                        YearOfEstablishment = Convert.ToInt32(addField2.Text)
                    };
                    await UpdateItemAsync(obj, "studios", cellValueInt);
                }

                MessageBox.Show("Successfully updated data!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.Trim() + " Failed to update data!");
            }
            LoadWindow(0);
        }
Exemple #35
0
        protected override async Task OnInitializedAsync()
        {
            int id = Convert.ToInt32(Id);

            Model = await _repo.Get(EndPoints.StudioEndpoint, id);
        }
 public void Update(Studio studio)
 {
     this.data.Update(studio);
     this.data.SaveChanges();
 }
        public BaseItem GetItem(BaseItemDto mb3Item, string itemType)
        {
            var item = InstantiateItem(itemType, mb3Item);

            if (item != null)
            {
                item.Name = mb3Item.Name;
                //Logger.ReportVerbose("Item {0} is {1}", item.Name, item.GetType().Name);
                item.Path             = mb3Item.Path;
                item.DateCreated      = (mb3Item.DateCreated ?? DateTime.MinValue).ToLocalTime();
                item.DisplayMediaType = mb3Item.DisplayMediaType;
                item.Overview         = mb3Item.Overview;
                item.SortName         = mb3Item.SortName;
                item.TagLine          = mb3Item.Taglines != null && mb3Item.Taglines.Count > 0 ? mb3Item.Taglines[0] : null;
                item.UserData         = mb3Item.UserData;
                item.PremierDate      = mb3Item.PremiereDate ?? DateTime.MinValue;
                item.FirstAired       = mb3Item.PremiereDate != null?mb3Item.PremiereDate.Value.ToLocalTime().ToString("ddd d MMM, yyyy") : null;

                item.EndDate             = mb3Item.EndDate ?? DateTime.MinValue;
                item.ProductionYear      = mb3Item.ProductionYear ?? item.PremierDate.Year;
                item.ProductionLocations = mb3Item.ProductionLocations;
                //Logger.ReportInfo("*********** Premier Date for {0} is {1}",item.Name,item.PremierDate);
                item.ApiParentId = mb3Item.ParentId;
                //if (item.ApiParentId == null) Logger.ReportVerbose("Parent Id is null for {0}",item.Name);
                item.LocationType = mb3Item.LocationType;
                // recursive media count
                item.ApiRecursiveItemCount = mb3Item.RecursiveItemCount;
                item.ApiItemCount          = mb3Item.ChildCount;
                // disc status
                item.IsOffline      = mb3Item.LocationType == LocationType.Offline;
                item.IsExternalDisc = mb3Item.IsPlaceHolder ?? false;
                // playback access
                item.PlaybackAllowed = (mb3Item.PlayAccess == PlayAccess.Full) && !(mb3Item.IsPlaceHolder ?? false);
                // delete access
                item.CanDelete = mb3Item.CanDelete ?? false;

                //Ratings
                item.CriticRating        = mb3Item.CriticRating;
                item.CriticRatingSummary = mb3Item.CriticRatingSummary;
                item.MetaScore           = mb3Item.Metascore;

                //SpecialFeatures
                item.SpecialFeatureCount = mb3Item.SpecialFeatureCount ?? 0;

                //Counts
                item.MovieCount      = mb3Item.MovieCount ?? 0;
                item.SeriesCount     = mb3Item.SeriesCount ?? 0;
                item.EpisodeCount    = mb3Item.EpisodeCount ?? 0;
                item.TrailerCount    = mb3Item.LocalTrailerCount ?? 0;
                item.GameCount       = mb3Item.GameCount ?? 0;
                item.SongCount       = mb3Item.SongCount ?? 0;
                item.AlbumCount      = mb3Item.AlbumCount ?? 0;
                item.MusicVideoCount = mb3Item.MusicVideoCount ?? 0;


                var runTimeTicks = mb3Item.RunTimeTicks;
                item.RuntimeTicks = runTimeTicks ?? 0;

                var index = item as IndexFolder;
                if (index != null)
                {
                    index.Id      = mb3Item.Id.GetMD5();
                    index.IndexId = mb3Item.Id;
                }
                else
                {
                    item.Id = new Guid(mb3Item.Id);
                }

                if (mb3Item.ImageTags != null)
                {
                    foreach (var tag in mb3Item.ImageTags)
                    {
                        switch (tag.Key)
                        {
                        case ImageType.Primary:
                            if (mb3Item.HasPrimaryImage)
                            {
                                item.PrimaryImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxPrimaryWidth, CropWhitespace = false
                                });
                            }
                            break;

                        case ImageType.Logo:
                            if (mb3Item.HasLogo)
                            {
                                item.LogoImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxLogoWidth, CropWhitespace = false
                                });
                            }
                            break;

                        case ImageType.Art:
                            if (mb3Item.HasArtImage)
                            {
                                item.ArtImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxArtWidth, CropWhitespace = false
                                });
                            }
                            break;

                        case ImageType.Banner:
                            if (mb3Item.HasBanner)
                            {
                                item.BannerImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxBannerWidth, CropWhitespace = false
                                });
                            }
                            break;

                        case ImageType.Thumb:
                            if (mb3Item.HasThumb)
                            {
                                item.ThumbnailImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxThumbWidth, CropWhitespace = false
                                });
                            }
                            break;

                        case ImageType.Disc:
                            if (mb3Item.HasDiscImage)
                            {
                                item.DiscImagePath = GetImageUrl(item, new ImageOptions {
                                    ImageType = tag.Key, Tag = tag.Value, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxDiscWidth, CropWhitespace = false
                                });
                            }
                            break;
                        }
                    }
                }

                if (mb3Item.BackdropImageTags != null && mb3Item.BackdropCount > 0)
                {
                    var ndx = 0;
                    item.BackdropImagePaths = new List <string>();
                    foreach (var bd in mb3Item.BackdropImageTags)
                    {
                        item.BackdropImagePaths.Add(Kernel.ApiClient.GetImageUrl(mb3Item.Id, new ImageOptions {
                            ImageType = ImageType.Backdrop, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxBackgroundWidth, Tag = bd, ImageIndex = ndx
                        }));
                        ndx++;
                    }
                }

                var folder = item as Folder;
                if (folder != null)
                {
                    // Collection Type
                    folder.CollectionType = mb3Item.CollectionType;
                    // Fill in display prefs
                    folder.DisplayPreferencesId = mb3Item.DisplayPreferencesId ?? mb3Item.Id;

                    // cumulative runtime
                    if (mb3Item.CumulativeRunTimeTicks != null)
                    {
                        folder.RunTime = (int)(mb3Item.CumulativeRunTimeTicks / TimeSpan.TicksPerMinute);
                    }

                    // unwatched count
                    if (mb3Item.UserData != null && mb3Item.UserData.UnplayedItemCount.HasValue)
                    {
                        folder.UnwatchedCount = mb3Item.UserData.UnplayedItemCount.Value;
                    }
                    // it is just too slow to try and gather these as channels are dynamic and potentially large
                    else if (mb3Item.Type == "Channel" || mb3Item.Type == "ChannelFolder")
                    {
                        folder.UnwatchedCount = 0;
                    }

                    // we want our created date to be the date of last item we contain
                    folder.DateCreated = mb3Item.DateLastMediaAdded ?? folder.DateCreated;
                }

                var video = item as Video;
                if (video != null && video.Path != null)
                {
                    video.ContainsTrailers = mb3Item.LocalTrailerCount > 0;
                    if (mb3Item.Video3DFormat != null)
                    {
                        video.VideoFormat = mb3Item.Video3DFormat == Video3DFormat.FullSideBySide || mb3Item.Video3DFormat == Video3DFormat.HalfSideBySide ? "Sbs3D" : "Digital3D";
                        video.Is3D        = true;
                    }
                    else
                    {
                        video.VideoFormat = "Standard";
                    }

                    // Chapters
                    if (mb3Item.Chapters != null)
                    {
                        var ndx = 0;
                        video.Chapters = mb3Item.Chapters.Select(c => new Chapter {
                            ApiParentId = mb3Item.Id, PositionTicks = c.StartPositionTicks, Name = c.Name, PrimaryImagePath = c.HasImage ? GetImageUrl(video, new ImageOptions {
                                Tag = c.ImageTag, ImageType = ImageType.Chapter, ImageIndex = ndx++
                            }) : null
                        }).ToList();
                    }
                }

                var media = item as Media;
                if (media != null)
                {
                    media.PartCount    = mb3Item.PartCount ?? 1;
                    media.MediaSources = mb3Item.MediaSources;

                    if (mb3Item.MediaType == Model.Entities.MediaType.Video)
                    {
                        if (mb3Item.VideoType == VideoType.VideoFile && media.Path != null)
                        {
                            media.MediaType = MediaTypeResolver.DetermineType(media.Path);
                        }
                        else
                        {
                            switch (mb3Item.VideoType)
                            {
                            case VideoType.BluRay:
                                media.MediaType = MediaType.BluRay;
                                break;

                            case VideoType.Dvd:
                                media.MediaType = MediaType.DVD;
                                break;

                            case VideoType.Iso:
                                media.MediaType = MediaType.ISO;
                                break;

                            default:
                                media.MediaType = MediaType.Unknown;
                                break;
                            }
                        }
                    }
                    else
                    {
                        media.MediaType = MediaTypeResolver.DetermineType(media.Path);
                    }

                    if (mb3Item.MediaStreams != null)
                    {
                        var vidStream   = mb3Item.MediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);
                        var audStream   = mb3Item.MediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Audio && s.IsDefault) ?? mb3Item.MediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Audio);
                        var subtStreams = mb3Item.MediaStreams.Where(s => s.Type == MediaStreamType.Subtitle && !string.IsNullOrEmpty(s.Language)).Select(s => s.IsForced ? s.Language.ToUpper() : s.Language).ToArray();
                        media.MediaStreams = mb3Item.MediaStreams;
                        media.AspectRatio  = !string.IsNullOrEmpty(mb3Item.AspectRatio) ? mb3Item.AspectRatio : null;
                        media.SubTitle     = subtStreams.Any() ? string.Join(", ", subtStreams) : null;

                        media.MediaInfo = new MediaInfoData
                        {
                            OverrideData = new MediaInfoData.MIData
                            {
                                AudioStreamCount  = mb3Item.MediaStreams.Count(s => s.Type == MediaStreamType.Audio),
                                AudioBitRate      = audStream != null ? audStream.BitRate ?? 0 : 0,
                                AudioChannelCount = audStream != null?TranslateAudioChannels(audStream.Channels ?? 0) : "",
                                                        AudioFormat                              = audStream != null ? audStream.Codec == "dca" ? audStream.Profile : audStream.Codec : "",
                                                        VideoBitRate                             = vidStream != null ? vidStream.BitRate ?? 0 : 0,
                                                        VideoCodec                               = vidStream != null ? vidStream.Codec : "",
                                                        VideoFPS                                 = vidStream != null?vidStream.AverageFrameRate.ToString() : "",
                                                                                       Width     = vidStream != null ? vidStream.Width ?? 0 : 0,
                                                                                       Height    = vidStream != null ? vidStream.Height ?? 0 : 0,
                                                                                       Subtitles = subtStreams.Any() ? string.Join(", ", subtStreams) : null,
                                                                                       RunTime   = runTimeTicks != null?ConvertTicksToMinutes(runTimeTicks) : 0
                            }
                        };
                    }
                    if (mb3Item.UserData != null)
                    {
                        media.PlaybackStatus = PlaybackStatusFactory.Instance.Create(media.Id);
                        media.PlaybackStatus.PositionTicks = mb3Item.UserData.PlaybackPositionTicks;
                        media.PlaybackStatus.PlayCount     = mb3Item.UserData.PlayCount;
                        media.PlaybackStatus.WasPlayed     = mb3Item.UserData.Played || mb3Item.LocationType == LocationType.Virtual;
                        media.PlaybackStatus.LastPlayed    = (mb3Item.UserData.LastPlayedDate ?? DateTime.MinValue).ToLocalTime();
                    }
                }

                var show = item as IShow;
                if (show != null)
                {
                    show.MpaaRating  = mb3Item.OfficialRating;
                    show.ImdbRating  = mb3Item.CommunityRating;
                    show.RunningTime = runTimeTicks != null ? (int?)ConvertTicksToMinutes(runTimeTicks) : null;

                    if (mb3Item.Genres != null)
                    {
                        show.Genres = new List <string>(mb3Item.Genres);
                    }

                    if (mb3Item.People != null)
                    {
                        show.Actors    = new List <Actor>(mb3Item.People.Where(p => p.Type == PersonType.Actor || p.Type == PersonType.GuestStar).Select(a => new Actor(a)));
                        show.Directors = new List <string>(mb3Item.People.Where(p => p.Type == PersonType.Director).Select(a => a.Name));
                    }

                    if (mb3Item.Studios != null)
                    {
                        show.Studios = new List <string>(mb3Item.Studios.Select(s => s.Name));
                        foreach (var studio in mb3Item.Studios.Where(s => s != null))
                        {
                            Studio.AddToCache(studio);
                        }
                    }
                }

                var episode = item as Episode;
                if (episode != null)
                {
                    var indexDisplay = mb3Item.IndexNumber != null && mb3Item.IndexNumber > 0 ? mb3Item.IndexNumber + (mb3Item.IndexNumberEnd != null ? "-" + mb3Item.IndexNumberEnd : "") + " - " : "";
                    episode.Name          = indexDisplay != "" ? indexDisplay + episode.Name : episode.Name;
                    episode.EpisodeNumber = mb3Item.IndexNumber != null?mb3Item.IndexNumber.Value.ToString("#00") : null;

                    episode.SeasonNumber = mb3Item.ParentIndexNumber != null?mb3Item.ParentIndexNumber.Value.ToString("#00") : null;

                    episode.SeriesId = mb3Item.SeriesId;
                    episode.SeasonId = mb3Item.SeasonId;
                    if (mb3Item.AirsAfterSeasonNumber != null)
                    {
                        episode.SortName = mb3Item.AirsAfterSeasonNumber.Value.ToString("000") + "-999999" + mb3Item.SortName;
                    }
                    else
                    if (mb3Item.AirsBeforeSeasonNumber != null && mb3Item.AirsBeforeEpisodeNumber != null)
                    {
                        episode.SortName = mb3Item.AirsBeforeSeasonNumber.Value.ToString("000") + "-" + ((int)(mb3Item.AirsBeforeEpisodeNumber - 1)).ToString("0000") + ".5" + mb3Item.SortName;
                    }
                }

                var season = item as Season;
                if (season != null)
                {
                    season.SeasonNumber = (mb3Item.IndexNumber ?? 0).ToString("000");
                }
                else
                {
                    var series = item as Series;
                    if (series != null)
                    {
                        series.Status       = mb3Item.Status;
                        series.AirTime      = mb3Item.AirTime;
                        series.ImdbRating   = mb3Item.CommunityRating;
                        series.CriticRating = mb3Item.CriticRating;
                        series.AirDay       = mb3Item.AirDays != null?mb3Item.AirDays.FirstOrDefault().ToString() : null;
                    }
                }


                var song = item as Song;
                if (song != null)
                {
                    song.Album        = mb3Item.Album;
                    song.AlbumArtist  = mb3Item.AlbumArtist;
                    song.AlbumId      = mb3Item.AlbumId;
                    song.Artist       = mb3Item.Artists.FirstOrDefault();
                    song.CriticRating = mb3Item.CommunityRating;
                }

                var album = item as MusicAlbum;
                if (album != null)
                {
                    album.AlbumArtist = mb3Item.AlbumArtist ?? mb3Item.Artists.FirstOrDefault();
                }

                var photo = item as Photo;
                if (photo != null)
                {
                    if (mb3Item.HasPrimaryImage)
                    {
                        //Make the photo itself also the backdrop so it can preview large and play back at full-res
                        item.BackdropImagePaths = new List <string> {
                            Kernel.ApiClient.GetImageUrl(mb3Item.Id, new ImageOptions {
                                ImageType = ImageType.Primary, Quality = Kernel.Instance.CommonConfigData.JpgImageQuality, MaxWidth = Kernel.Instance.CommonConfigData.MaxBackgroundWidth, Tag = mb3Item.ImageTags[ImageType.Primary]
                            })
                        };
                    }

                    if (string.IsNullOrEmpty(photo.Overview))
                    {
                        if (photo.DateTaken != DateTime.MinValue || !string.IsNullOrEmpty(mb3Item.CameraMake) || !string.IsNullOrEmpty(mb3Item.CameraModel))
                        {
                            photo.Overview = string.Format("Taken {0} with a {1} {2}\n", photo.DateTaken > DateTime.MinValue ? photo.DateTaken.ToShortTimeString() : "", mb3Item.CameraMake, mb3Item.CameraModel);
                        }
                        photo.Overview += string.Format("Original Resolution {0}x{1}", mb3Item.Width, mb3Item.Height);
                        if (mb3Item.ShutterSpeed != null)
                        {
                            photo.Overview += string.Format(" Shutter Speed {0}\n", mb3Item.ShutterSpeed);
                        }
                    }
                }

                // Finally, any custom values
                item.FillCustomValues(mb3Item);
            }
            else
            {
                Logger.ReportWarning("Ignoring invalid item " + itemType + ".  Would not instantiate in current environment.");
            }


            return(item);
        }
        private static void OnStudioChange(Studio newStudio)
        {
            var newTitleId = (newStudio.Titles == null || newStudio.Titles.Length == 0) ? "" : newStudio.Titles[0].Id;

            OnTitleIdChange(newTitleId);
        }
 public void Verify_MapToEntity_WithExistingEntity_AssignsStudioProperties()
 {
     // Arrange
     var mapper = new StudioMapper();
     var model = StudiosMockingSetup.DoMockingSetupForStudioModel();
     // Act
     IStudio existingEntity = new Studio { Id = 1 };
     mapper.MapToEntity(model.Object, ref existingEntity);
     // Assert
     // <None>
     // Related Objects
     // <None>
     // Associated Objects
     model.VerifyGet(x => x.MovieStudios, Times.Once);
     //Assert.Equal(model.Object.MovieStudios?.Count, existingEntity.MovieStudios?.Count);
 }