Hi gurus,
The company in which I work experiences in developing Windows Forms applications and we have developed a kind of 3-tired architecture for that kind of programs but for some business reasons we have to produce some web applications with ASP.NET and we have problems designing an architecture for these new apps because of the major differences between Web and Windows application models. I have studies some tutorials and articles about the various ways we may implement DAL and BIZ layers but in none of them I could find a solution for Master/Detail entities. In Master/Detail entities some business rules must be perfomed by Master entity over it's details. how can we keep the master entity alive while the end user is editing the items For instance in an accounting program a voucher has a master entitiy (containing the Voucher number and date) and some articles (like account number,price and ...). In this case Master entity can be saved only if sum of Debit and Credit values in all items are equal.
What can I do in such a case
Thanks

Master/Defail entities and architecture problem in ASP.NET
Participant
Hi Aref,
the problem you are facing happened to me before. The benefit of desktop applications is that you can "download" the master entity with its details, work with them "disconnected" from the database and update the whole entity once the user confirms his/her action
The contra of web applications is that one: they have no or little support for offline capabilities. What I used to do in those cases was taking a document-oriented approach. I mean: you mentioned you need to introduce some changes to a Voucher containing a list of Articles. So what I would do in your place is creating a document -serializable as XML if possible- to represent that Voucher info necessary for the use case (and nothing else)
That way, as the user is navigating through pages along that use case, you apply his/her actions to the document representing the transaction. Once the user confirms his/her changes, you validate the business rules against the document containing the final status for the voucher entity. If business rules are satisfied, you applied the changes to the Voucher entity and/or its Articles if necessary
Another chance you may want to explore is ASP.NET AJAX, http://ajax.asp.net/, which allows you some "disconnection" from the web server (and therefore from the data source) by allowing you to keep some use case status at the browser, without the need of unloading and loading new pages every time
Nightmare_BE
In Master/Detail entities some business rules must be perfomed by Master entity over it's details.
You must see a webapplication stateless. It is therefore better to apply the business rule when opening the master page again.
how can we keep the master entity alive while the end user is editing the items
If you want to keep the masterpage alive while a user is editing, you can use a sessions variable. Keep in mind that this can introduce a performance issue.
In this case Master entity can be saved only if sum of Debit and Credit values in all items are equal
The best way is to get the values of the mater with the PreviousPgae technique and keep this local in the detail page, so it will be session independent
Jason P
Hi there,
This problem is very common in web apps. The things that worked for me in the past where:
If you are handling the master and the detail information on the same page, you can keep the state on the view state. As the view states keeps the objects (Note: They've to be serializable) serialized and encryped when the page gots rendered and then when re-hidrates the object when a request occurss. If you have multiple forms and it's kindda wizard process, I suggest you to use a Wizard control of ASP.NET and keep it as a single page. Seems that this is the recommended for you, since you have a process (like wizard one)
If you're working across multiple pages you can use Session object, to perform the same operations listed above but accross multiple pages.
If you want to keep data across multiple sessions, and do not send or process that data till complettion and you want the user data process not to be tied to a session. I suggest you to review the Profile Object of the ASP.NET. (It's a SQLStore (by default) that works as the session but tides the UserIdentifier to the data instead of SessionIdentifier).
Thanks,
~johnny
http://staff.southworks.net/johnny
Was this post helpul If it was, please tag it as resolved :)