I recently started my first C# course in school and we´re supposed to work with three layer architecture on our course project. The problem is that I don't seem to pass object between layers. I have a main GUI layer with a textbox input where the user shall pass in an URL to a podcast. This podcast is then supposed to move to the logic layer and then down to the data layer where a serialization process is started. I´m using a couple of classes to make this possible.
GUI layer: -"Main" This is where the user puts in a URL. Current code for add button:
private void btnUrl_Click(object sender, RoutedEventArgs e)
{
FeedItem feed = new FeedItem();
var url = tbUrl.Text;
feed.Url = url;
feedservice.Save(feed);
}
Logic: -"FeedItem" this is what I´m trying to send.
Logic: -"FeedService" this is supposed to be the middle ground between GUI and data.
public class Feedservice
{
internal static XmlSerializer Xml;
private static List<FeedItem> Feedlista = new List<FeedItem>();
private Dataklass<List<FeedItem>> feeds;
public void Save(FeedItem nyFeed)
{
if (nyFeed.Url == null)
{
Console.Write("Du måste ge boxen en URL!");
}
Feedlista.Add(nyFeed);
feeds.XMLFeed(Feedlista);
}
}
Data: -"Dataklass" This is where I will start the serialization and path back to the listbox on "Main". When finished it´s supposed to be a podcast handler where the user can select a podcast and then play it with a media player of choice.
I can't seem to get the FeedItem object to be passed to the logic layer without getting a Nullexception error. Am I on the right path here or am I completely lost? If anyone got some kind of input I would appreciate it alot!