Old book store website

Introduction story:

Last night while i was talking with my little sister about her exercise: Making a website to sell old/unused book. She is studying business matter. Wow a good idea! Suddenly i came up with a site doing nearly the same thing. It is for Sharing books. Basically it is quite different since i am not making any business here or gain any money from that action.

Let start with the story. When i was at the university, every semater i spent lots of money on books. Event though the true was not 🙁 since i was not so interested in those books at all. And then when it came over, where those books went? They became garbage; a waste of money. And the cycle begins with new comers. So what can we do? Instead of buying the new ones, we can ask for them with lower price or even free ( if you meet a generous guy).

What is the obstacle in that solution? The communication: how do you know where/who to ask for? Therefore, the site i am going to build is a meant to solve that issue. Of course it needs help from many people especially the ones who have old books.

Let summary the process:

  1. Book owner publishes books into the site.
  2. People needing book go in and search for them.
  3. He, then, contacts with book owner for a deal.
  4. Book owner updates the available number of that book or remove them if out of stock.

Simple 🙂

Version 1.o:

The very first version should be simple and supply enough functionalities: search, upload, manage books. Below are stories in this version. The search GUI should be something like google. As simple as possible.
 
User stories:
 
Story 1: Seeking for books
As a normal user who is looking for a book without registered
I want to look for books by name
When i enter the name
Then the system should return to me list of books with having that name in their name and i should know the author as well as the description.
 
Story 2: Registration is required when uploading book
As a normal user having some books
I want to share or sell to others
When i ask for that task
Then the system requires her/him to register into the system. When done, redirect them to the upload page.
 
Story 3: Register user
As a normal user
I am required to register in.
Then the system show me form to fill in information: Name(required), Email, Phone, Address(required)

 

Story 4: Upload book
As a registered user
I want to upload book i have into the site
When i ask for it
Then the system should show me the GUI to allow entering book details: Name, Author, Type, Description, Available amount, Price
 
Story 5: Display my books
As a registered user
I want to see all books uploaded by myself
When i log in and want to see them
Then the system should list them out
 
Story 6: Remove books
As a register user
I want to remove some books since they have been bought or free-given
When i am in my display books
Then i should be possible to remove them and they no longer appear in the site.
 
Story 7: Added/changed book displays immediately
As a registered user
I want to see my added book shown immediately in the list
When i finish adding one book
Then the book should appear immediately on the list.
 
Story 8: Only me or addministrator can remove/change my books
As a registered user
I try to remove or change info of books which are not mine
Then i have no way to do that.
 
Story 9: Show total visitor so far and today
As a user goes in the site
I want to know how many people has visited the site so far
When i am in the home page, the page to search books
Then the system shows me that number and the number of today.

30-4 vacation BMT

So great! I have not been on vacation for long time. Usually, when having vacation days, i go to my hometown, staying with my family, It was fine. Thing changed! I took a vacation for 4 days going to Buon Ma Thuat City.

The very first word, i want to say thank you to my friends in Buon Ma Thuat: Van Anh, Her boyfriend, Le Vi, and his friends. They are soooo nice and guide me visiting many places. We really had happy time staying there.

Back to the trip, it took about 7 hours to get there, about 350KM far from HCM city, 150K/person for the ticket. The bus stopped at Bu Dang station for upping your power and toilet as well.

Bu Dang
Bu Dang

After 30 minutes at Bu Dang, Got in the bus and drove straightforward to Buon Ma Thuat city. Even thought, it was a long trip, we did not get tired since sleeping all the time on bus.

Bravo, Welcome to BMT, the first feeling was: the fresh, cool atmostphere. Checked in the hotel, took a rest and started with first day.

Day 1: Buon Don, 40km from Buon Ma Thuat city

We decided to target at Buon Don. My friend, VA with his boyfriend, took us for breakfast and morning coffee. Driving on the road to Buon Don york, suddenly i felt something strange: Hic the after tire broke. No problem, i got the nouvo one from his brother :). From that on, i got it for the left days:

motobike

Eventually i got to Buon Don, ticket costs 20/person.

bamboo chain-bridge

The bamboo chain-bridge used to navigate there. Wow, it was a little bit worry for the first time. However, it was exciting :). There were not much sight seeings here. The interesting things were that i knew it and felt like it. It is best for outdoor activity. You can bring food, beer, water or whatever to eat, drink in and enjoy with your friend. Here are some pics taken there:

treeupdown

mygirlfriend

Here is the food i used and the elephan:

foodatbuondonelephan

We also went to another place however it was not so exciting. it was peaceful.

Day 2: Draysap waterfall ( DakNong province). About 30km from Buon Ma Thuat city

As normal, we started with breakfast and coffee for a new day. I love coffee so much.

We went to the waterfall with other friends from my friend Vi. We were a group of 9 people on moto bikes.

dsc00618

dsc00623

dsc00657

dsc00656

More will go on with next post.

NHibernate first attemp in blog system

As mention in the previous post, i started my application with first try in NHibernate. Wow it was sweat try. Eventually i got it works.

After nearly 4 hours fighting with NHibernate and my application, i had these in general:

general structure
general structure

Let says a little bit about them before continuing:

  • AnhDuc.Blog: Web site application
  • AnhDuc.Blog.Business: Project contains all business logics for the site
  • AnhDuc.Common: Project contains common things which can be used widely or in other projects.

Since i was using NHibernate then there was not DataAccess project.

Time to talk about using NHibernate. I have read some article and NHibernate In Action book to accomplish the usage. Basically here are steps:

Required Dlls:

Download NHibernate dlls and other required dlls. You can easy get them by using your friend: Google, thus i do not mention here.

Configuration:

First, you need these in webconfig. All you need to do is copy this part and paste in your config then change the connection string to the right one: 

< hibernate-configuration xmlns=urn:nhibernate-configuration-2.2 >
< session-factory>
<property name=connection.driver_class>NHibernate.Driver.SqlClientDriver</property>
<property name=connection.connection_string>Server=(local);initial catalog=anhduc_blog;Integrated Security=SSPI</property>
<property name=adonet.batch_size>10</property>
<property name=show_sql>false</property>
<property name=dialect>NHibernate.Dialect.MsSql2000Dialect</property>
<property name=use_outer_join>true</property>
<property name=command_timeout>60</property>
<property name=query.substitutions>true 1, false 0, yes ‘Y’, no ‘N’</property>
<property name=proxyfactory.factory_class>NHibernate.ByteCode.LinFu.ProxyFactoryFactory,

NHibernate.ByteCode.LinFu</property>

<mapping assembly=AnhDuc.Blog.Business />

</session-factory>

</hibernate-configuration>

Then i came with code to initialize the configuration: NHibernateSessionManager class.

public sealed class NHibernateSessionManager
{
private static readonly ISessionFactory _sessionFactory;
private const String CurrentSessionKey = “anhduc.blog.nhibernate.currentsession”;
static NHibernateSessionManager()
{
Configuration cfg = new Configuration();
//cfg.AddAssembly((typeof (BlogItem)).Assembly);
cfg.Configure();

_sessionFactory = cfg.BuildSessionFactory();
}

public static ISession GetCurrentSession()
{
HttpContext context = HttpContext.Current;
ISession session = context.Items[CurrentSessionKey] as ISession;
if(session==null)
{
session = _sessionFactory.OpenSession();
context.Items[CurrentSessionKey] = session;
}
return session;
}

public static void CloseCurrentSession()
{
HttpContext context = HttpContext.Current;
ISession session = context.Items[CurrentSessionKey] as ISession;
if (session == null)
return;
session.Close();
context.Items.Remove(CurrentSessionKey);
}

public static void CloseSessionFactory()
{
if (_sessionFactory != null)
_sessionFactory.Close();
}

public static void CommitTransaction()
{
GetCurrentSession().Transaction.Commit();
}

public static void AbortTransaction()
{
GetCurrentSession().Transaction.Rollback();
}
}

It contains some methods to deal with transaction.

The configuration is done, and ready to use. Come to your business class.

Business classes:

They are all under AnhDuc.Blog,Business project. Each class has its own mapping file. All mapping files are put under hbm folder. I am not going to explain in detail about mapping here. However, it is the most important thing when you work with NHibernate.

Be aware of inheritance when designing your domain. In many cases, inheritance is not encouraged.

Recommended book: NHibernate In Action June 2008

Blog system – introduction

So far i have read many articles about web application development. So general speaking, i have tools in hand to build a website in no time with less effort. Just need to structure code and deal with business logic.

Here are some:

  1. NHibernate: Deal with DataAccess layer and maybe more.
  2. AJAX data template , deal with binding data into grid, the GUI things
  3. IoC, from Windsor, and Mock from Rhino deal with DI and Unit testing
  4. jQuery to work with JavaScript
  5. NUnit to test my code

That’s quite enough! However i have never interated them in one application at all. That’s why i am going to make a simple web application to demonstrate my understanding.

The web is about a blog site with:

  1. List of categories on the left.
  2. Click on one category, then list out all blogs in that category in short.
  3. Click on one blog item, then the detail is displayed

Assuming that, all data will be added into DB directly. What i want to archive are:

  1. Of course, the system works
  2. Easy to extend, since i will add administrative functions later: Add, Edit, Delete,…
  3. Easy to maintain code.
  4. Apply all the things i have known so far, those i list above.

Along with the development process, i will update my blog. I am sure there will be more fun while doing it, yeah with difficulties as well.