Monday, August 10, 2015

Without further ado, this is how the eShop solution structure looks like when viewed in Visual Studio Solution Explorer:


You may notice we have 3 projects in a solution:

  1. Website: this is the website project, downloaded and extracted from Composite C1 zip file, installed (first time you run the website it will start Composite C1 installer - maybe better name is configurator, not installer?) and modified afterwards. Lets talk about Composite C1 a bit. It is a classical website, coded in C#. It has a routing system preset so you get nice URLs, no more convoluted .aspx links. Also, if you choose minimal razor template, it already has references to jQuery library, bootstrap, razor etc. That stuff is preset for you so you don't have to worry about it and waste time. Coolest thing about using bootstrap is that it just works, on all devices, all resolutions, you don't have to write a single line of CSS if you don't want to as everything is already there. There are also bootstrap interface builders available online for free where you can layout your page in minutes, copy the generated html and it will work on the site just like that. That is because generated html will have correct style classes selected for every html element and those style classes are defined by bootstrap. Another thing about Composite C1 is that all custom functionality that should be added on pages is contained in functions. Functions are like code units, containing the code, layout or both. For those coming from classical ASP.NET development world, user controls is something you do, day by day. You can create your function as user control, login to Composite C1 console and create a new page, layout it in Composite, add your function (user control) to this page and you are done. Recently, I moved away from the user controls as I stopped (well, almost) using code behind in my functions. I use Razor functions now as it makes writing html a breeze if you want to insert server tags, especially loops. No more percent signs for me, thank you (like <%= value from code behind %>). Loops are used when you want to display data from database in a repeater fashion. I also started heavily using Ajax calls, so my data is posted to service and response is sent back trough a service. A bit of JavaScript and Web Api controllers do the magic just fine. I will show more of this in my future posts, step by step. To take a look at what bootstrap has to offer take a peek here.
  2. DataLibrary is a class library containing the Entity Data Model, custom types (entities that are not in the edm nor database, custom types are basically classes with properties that represent custom views to aggregate data from multiple entities into one entity or abstract complex entity), methods that retrieve the data (static methods that query data using linq) and enumerations that represent lookup values. Data methods are placed here as they are reusable code, it makes maintenance much easier than to search your main project for linq queries. Enumerations makes code look nicer and make more sense (return clients where client type = individual makes more sense than return clients where client type = 1).
  3. WebLibrary class library contains custom security objects, helper classes, base classes and in this case, as this is an eShop solution, finance classes that abstract shopping cart and payment functionality. WebLibrary should also contain data caching classes, audit classes, resource objects etc. but these are not present as I mentioned in posts before, this is not production ready solution.
I will go into specific classes and explain more in future posts. For tomorrow, I will show database ER diagram and explain why we have 2 databases for the solution.

You can download full source code of the eShop website if you want to take a closer look yourself.

Thank you.

No comments:

Post a Comment