Introduction
Web RSS Builder is an open source application for managing RSS files using Web-based and Silverlight-based interfaces. This application is useful when you need to manage RSS files on the server using a web application.
The application is hosted on CodePlex at http://WebRSSBuilder.codeplex.com.
This is part 2 of a three-part post that will describe this application:
The ASP.NET Interface
This application will use the core component described earlier to provide a Web interface for managing RSS files. At first, let’s put a small website map of the main pages:
- Homepage: View files the user is responsible for
- View RSS: Responsible for viewing a specific RSS file
- Manage RSS Files
- Manage Roles
- Manage User Roles
- Manage Users
The priority is for the first three, since ASP.NET provides a web interface to manage the later three, but, still, it is nice to provide them all in the same web application.
View RSS Web Page
This webpage will be used to View and Edit an RSSFeed
Object, so Object data provider will be used to bind the RSSFeed
object to the ASP controls. For XML data sources, usually we can use XMLDataSource shipped with ASP.NET, I used object data source for a couple of reasons:
- It is cleaner: from an engineering perspective, decoupling the UI from application logic is important. Using such controls encourages bad practices since you won’t have a separation of concerns anymore with a View (webpage) that holds the business logic. I guess that Microsoft initiations in XAML (WPF and Silverlight), and ASP MVC shows clearly a feeling of guilt. Now, they are trying to encourage developers to start thinking differently, and discourage them from using the easy to use drag and drop data sources that was intended to make their life easier but it was only making it harder in the long term, with applications hard to test and maintain.
- To be able to reuse the Binding logic in different views, which bring us back to the first reason.
Building Object Data Provider to RSS Files
Now we have to build an Object data provider that will encapsulate the functionality provided by the core component. Object Data Provider should have five main methods: Get, Get All, Update, Delete and Add. So I have implemented RSSObjectDataProvider
this class will use RSSFeedXLinqController
to load and save Feed objects, this class contains:
- Pseudo properties that exposes the properties of the Feed object
- Load and Save Methods using
RSSFeedXLinqController
- CRUD methods, which are implemented simply to reflect these operations directly on the generic
RSSItem
list
The code of this provider is quite simple. That’s all.
#region Object Data Provider CRUD Methods
[DataObjectMethod(DataObjectMethodType.Select)]
public ObservableCollection GetAllItems()
{
return this.Feed.Items;
}
[DataObjectMethod(DataObjectMethodType.Select)]
public RSSItem GetItem(String id)
{
for (int i = 0; i < Feed.Items.Count; i++)
if (Feed.Items[i].Title == id)
return this.Feed.Items[i];
return null;
}
...
The Web Pages
View RSS Web Page
The Webpage contains Textbox
s that binds to the properties of the data provider, a Datagrid
and details view that contains HTML editor for the description of the RSS Item which binds directly to the data provider. I tried to make the code behind as minimal as it can be, but still you need to provide the URL of the feed to the object data provider which will be taken from a session variable. And I also cached the object data provider to allow better performance. This page, and the whole application, uses AJAX to provide a better user experience, all these controls are embedded inside an UpdatePanel
Managing Pages
As for the rest web pages, such as Managing Files and Managing Roles, it’s all done using LinqDataProvider
which uses the Entity Framework data context generated from the corresponding database tables.
Next Article
In the next article, we will go through the Silverlight application that will provide the same functionality of this application in a Silverlight one.
Did You Like the Article?
If you did, please vote for it. :)