I have an Area called Events. User can do there simply curd operations. Everything works finde. Now i have to include an XML Feed to this events. All events from the feed should be displayed with the events from the db.
I create an Interface IEventReadRepository and build to implementations from this class - one for the db and one for the rss feed. This works fine again, but only when i hardcode the mappings from the feed to the model (is there a better way?).
I’m not satisfied with my solution. In my case I use the same Model for the db – event and the rss event (tried with base class, but make no sense for me – they have the same attributes and methods).
The next problem is the id generation. An Event is displayed on the page only with the headline. If the user clicks on the link the controller gets the id from the event and redirect to the detail view.
Problem: The rss events do not have an id (And I don’t want to sync it to my database – I need them only to display).
I’m open for any suggestion to solve this problem in an elegant way.
Sorry for my confusing writting, hope u are able to understand it :).
I create an Interface IEventReadRepository and build to implementations from this class - one for the db and one for the rss feed. This works fine again, but only when i hardcode the mappings from the feed to the model (is there a better way?).
I would suggest to do it following way,
Get the entities from db
Create a rss feed parser to generate same type of entities or can be different
While parsing generate the temporary ids, you can use GUID or simple integer with some prefix to differentiate between DB & RSS
convert entities into model, you can use AutoMapper or ValueInjector. Once you have model you can bind them with ui. This way you will simplify the responsibility on each layer with appropriate business logic in place, your model will not know about the
id generation logic and your parser will be responsible to convert into entities which will be primary point to contact with model & service.
I'm working on my solution. I have added a new ServiceLayer in my Module, these service layer get all registered EventRepositories and bring the entities together.
I have to think about the id generation. I have an numeric id, so i have to take care that there is no duplicate id. Any Idea for this?
You can have prefix value to avoid that, if your db ids are identity value then you can prefix with 99????????, something like that, it will be temporary and will not get store anywhere, and I am sure your db values will not be that long.
benschi11
Member
16 Points
6 Posts
Display xml feed with entities from db
Jun 25, 2012 08:23 PM|LINK
Hi,
I have the following problem:
I have an Area called Events. User can do there simply curd operations. Everything works finde. Now i have to include an XML Feed to this events. All events from the feed should be displayed with the events from the db.
I create an Interface IEventReadRepository and build to implementations from this class - one for the db and one for the rss feed. This works fine again, but only when i hardcode the mappings from the feed to the model (is there a better way?).
I’m not satisfied with my solution. In my case I use the same Model for the db – event and the rss event (tried with base class, but make no sense for me – they have the same attributes and methods).
The next problem is the id generation. An Event is displayed on the page only with the headline. If the user clicks on the link the controller gets the id from the event and redirect to the detail view.
Problem: The rss events do not have an id (And I don’t want to sync it to my database – I need them only to display).
I’m open for any suggestion to solve this problem in an elegant way.
Sorry for my confusing writting, hope u are able to understand it :).
Thanks
CPrakash82
All-Star
18284 Points
2841 Posts
Re: Display xml feed with entities from db
Jun 25, 2012 11:12 PM|LINK
I would suggest to do it following way,
convert entities into model, you can use AutoMapper or ValueInjector. Once you have model you can bind them with ui. This way you will simplify the responsibility on each layer with appropriate business logic in place, your model will not know about the id generation logic and your parser will be responsible to convert into entities which will be primary point to contact with model & service.
Thanks,
benschi11
Member
16 Points
6 Posts
Re: Display xml feed with entities from db
Jun 26, 2012 12:17 PM|LINK
Thanks for your answer.
I'm working on my solution. I have added a new ServiceLayer in my Module, these service layer get all registered EventRepositories and bring the entities together.
I have to think about the id generation. I have an numeric id, so i have to take care that there is no duplicate id. Any Idea for this?
Thanks
CPrakash82
All-Star
18284 Points
2841 Posts
Re: Display xml feed with entities from db
Jun 26, 2012 12:46 PM|LINK
You can have prefix value to avoid that, if your db ids are identity value then you can prefix with 99????????, something like that, it will be temporary and will not get store anywhere, and I am sure your db values will not be that long.
Thanks,
benschi11
Member
16 Points
6 Posts
Re: Display xml feed with entities from db
Jun 27, 2012 08:36 PM|LINK
Thanks, you helped me a lot