asked on
if(tv.Shows.Exists(show => show.TMBDBid == 77236))
{
Console.WriteLine("A Discovery Of Witches Exists");
}
else
{
tv.Shows.Add(new Show()
{
Name = "A Discovery Of Witches",
FolderName = "A Discovery Of Witches",
TMBDBid = 77236
});
}
if (tv.Shows.Exists(show => show.TMBDBid == 67133 && show.Season.SeasonNumber))
// AND this
if (tv.Shows.Exists(show => show.TMBDBid == 67133 && show.Season => Season.SeasonNumber))
foreach (Show show in tv.Shows)
{
// Print out what TV shows are listed
string ShowName = show.Name;
string ShowID = show.TMBDBid.ToString();
Console.WriteLine("ShowName: {0}, TMBDBid: {1} ", ShowName, ShowID);
foreach (Season season in show.Season)
{
String SeasonNumber = season.SeasonNumber.ToString();
Console.WriteLine("SeasonNumber: {0}", SeasonNumber);
}
foreach(Episode episode in show.season.)
{
// How do I list the episodes?
// Error CS1061 'Show' does not contain a definition for 'season' and no extension method 'season' accepting a first argument of type 'Show' could be found
}
}
ASKER
Season s = show.Seaon.Where( ss => ss.SeasonNumber == "3").FirstOrDefault();
if (s != null)
{
foreach(Episode episode in s)
{
// do something
}
}
else
{
// no info for that season number.
}
ASKER
if (tv.Shows.Where(show => show.TMBDBid == 67133).FirstOrDefault() != null)
{
// check for season
Season s = show.Seaon.Where( ss => ss.SeasonNumber == "3").FirstOrDefault();
if (s != null)
{
Episode e = s.Episode.Where(ee => ee.EpisodeNumber == "1").FirstOrDefault();
if(e == null)
{
// Add new episode
}
}
else
{
// no info for that season number.
}
}
ASKER
The name 'show' does not exist in the current context
ASKER
public class Season
{
public int SeasonNumber { get; set; }
public Episode Episode { get; set; }
}
To public class Season
{
public int SeasonNumber { get; set; }
public List<Episode> Episode { get; set; } = new List<Episode>();
}
<Season>
<Season>
<SeasonNumber>3</SeasonNumber>
<Episode>
<Episode>
... etc
</Episode>
</Episode>
</Season>
</Season>
It would be nice if it could be <Seasons>
<Season>
<SeasonNumber>3</SeasonNumber>
<Episodes>
<Episode>
... etc
</Episode>
</Episodes>
</Season>
</Seasons>
I'm unsure how to achieve this other than add more classes ? ? public class Season
{
public int SeasonNumber { get; set; }
public List<Episodes> Episodes { get; set; }
}
public class Episodes
{
public List<Episode> Episode { get; set; } = new List<Episode>();
}
public class Episode
{
public int EpisodeNumber { get; set; }
public string EpisodeName { get; set; }
public string BackDrop { get; set; }
public string FullPath { get; set; }
}
public List<Episode> Episodes { get; set; } = new List<Episode>();
ASKER
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.
TRUSTED BY
Open in new window