# Saturday, September 03, 2011

In this post I want to show you how to create a very simple Windows Console client for The Smart Shopping List using Visual Studio & the RestSharp REST library.

  • Create a Windows Console Application using Visual Studio

image

 

image

 

  • Add the following code
image

 

  • When you build & run the application you should get an output similar to this:

image

You could also create, read, update & delete (CRUD) Stores, Product Categories, Products & Shopping List. Please check this post for more information.   

posted on Saturday, September 03, 2011 8:03:49 PM UTC  #    Comments [0]
# Friday, September 02, 2011

You can access The Smart Shopping List Web Api from any client as follows:

image

  • On the Edit Shopper screen press Save

image

  • When The Smart Shopping List Home page displays then you are registered

image

Accept: application/vnd.cyberbizsoft.ssl+xml

Authorization: Basic Your-User-ID:Your-Password (Base64 encoded)

When using POST, PUT & DELETE you must also add:

Content-Type: application/vnd.cyberbizsoft.ssl+xml

The entry point will provide the links that are available and as you add stores, products, etc. the application state will be updated.

image

posted on Friday, September 02, 2011 4:29:35 PM UTC  #    Comments [0]
# Wednesday, July 20, 2011

On a previous post I outlined a procedure for implementing ReSTful Web Services. In this post I will expand that outline with the design/implementation of a Web Api for The Smart Shopping List.

Figure 1 shows a class diagram of the simple domain model for The Smart Shopping List.

SSLDomain

Figure 1. The Smart Shopping List domain model

As you can see we have a Shopper that could have zero to many Stores and also zero to many Shopping Lists.

Each Store could have zero to many Product Categories and also zero to many Products.

Each Shopping List could have zero to many Products along with some other information.

Figure 2 shows a class diagram of the logical resources that will represent our Web Api.

SSLResources

Figure 2.The Smart Shopping List Resource Model

We have one entry point logical resource named Smart Shopping List, that advertises the Store  & the Shopping List logical resources for each Shopper.

The Store logical resource contains two logical sub-resources Product Category & Product  and the Shopping List logical resource has one Detail logical sub-resource.

Those logical resources and sub-resources are named by their Uris as depicted in Table 1.

Logical Resource Uri
SmartShoppingListResource ""
StoreResource "stores"
  "stores/{storeid}/productcategories"
  "stores/{storeid}/products"
ShoppingListResource "shoppinglists"
  "shoppinglists/{shoppinglistid}/detail"

Table 1. Logical Resources Uris

Each logical resource also implement a subset of the uniform interface as Table 2 shows.

Method Uri Description Result
GET "" Request current Status of The Smart Shopping List A representation of The Smart Shopping List  status
" "stores" Request all the Stores of the current Shopper

If success,  return 200 and a list representation. If not, 400. 

" "stores/productcategories" Request all the Product Categories of the current Shopper "
" "stores/{sid}/productcategories" Request all the Product Categories in a Store "
" "stores/products" Request all the Products of the current Shopper "
" "stores/{id}/products" Request all the Products in a Store "
" "shoppinglists" Request all the Shopping Lists of the current Shopper "
" "stores/{id}" Request the current state of a Store If success, return 200 and a single representation with its status. If not, 304, 400 or 404.
" "stores/productcategories/{id}" Request the current state of a Product Category "
" "stores/products/{id}" Request the current state of a Product "
" "shoppinglists/{id}" Request the current state of a Shopping List "
" "shoppinglists/{slid}/details" Request all the Detail in a Shopping List "
" "shoppinglists/{slid}/details/{id}" Request the current state of a Shopping List Detail "
POST "stores" Create a new Store for the current Shopper If success, return 201 a Location header & with the new representation & its status. If not, 204, 400 or 409
" "stores/{id}/productcategories" Creates a new Product Category for a Store "
" "stores/{id}/products" Creates a new Product  for a Store "
" "shoppinglists" Creates a new Shopping List for the current Shopper "
" "shoppinglists/{slid}/details" Creates a new Detail for a Shopping List "
PUT "stores/{id}" Updates a Store If success, return 200 with the representation & its status. If not, 204, 400, 404 or 409
" "stores/{sid}/productcategories/{id}" Updates a Product Category "
" "stores/{sid}/products/{id}" Updates a Product "
" "shoppinglists/{id}" Updates a Shopping List "
" "shoppinglists/{slid}/details/{id}" Updates a Shopping List's Detail "
DELETE "stores/{id}" Removes a Store If success return 200. If not 204, 400, 404 or 409
" "stores/{sid}/productcategories/{id}" Removes a Product Category "
" "stores/{sid}/products/{id}" Removes a Product "
" "shoppinglists/{id}" Removes a Shopping List "
" "shoppinglists/{slid}/details/{id}" Removes a Shopping List's Detail "

Table 2. Logical Resource Uniform Interface subset

Figure 3 shows that each logical resource has two representations one for a single resource and another for its collection along with its status.

SSLResourceRepresentations

Figure 3. The Smart Shopping List Resource Representation Model

Also each resource representation contains links that advertises the logical resource status.

For the implementation I have used preview 4 of the WCF Web Api and I will be adding this code later this week (if everything goes smoothly Smile) to The Smart Shopping List Source Code. You also will be able to "test drive" The Smart Shopping List at https://webapi.smartshoppinglist.net but you have to create a Smart Shopping List account and also use the following headers with your client:

Accept: application/vnd.cyberbizsoft.ssl+xml

Authorization: Basic Your-User-ID:Your-Password (Base64 encoded)

When using POST, PUT & DELETE you must also add:

Content-Type: application/vnd.cyberbizsoft.ssl+xml

Just point your client to https://webapi.smartshoppinglist.net and follow the protocol.

image 

Figure 4. Sample POSTing session using Fiddler.

posted on Wednesday, July 20, 2011 3:07:07 AM UTC  #    Comments [0]
# Tuesday, March 15, 2011
Design Notes
  • Application is computerized behavior to achieve a business goal
  • Application Protocol is a set of rules of allowed/legal interactions in an Application
  • Application State is an instant of time of the Application
  • URIs are used for resource identification
  • HTTP Methods/Verbs are used as the Uniform Interface
  • Resources are a logical representation of the Domain Model/Data Set
  • Resource Representations are transformations/views of Resources state at an instant of time
  • Resource Representations are requested via headers
  • There is a one to many relationship between a resource and its representations
  • Access to Resources is always mediated by way of Resource Representations
  • Hypermedia Resource Representation allows lazy-cacheable access that advertise permitted transitions
  • Use Transaction Resources to create stateless interaction
Design Procedure
  1. Figure out the Domain Model/Data Set (if it does not already exists)
  2. Split the Domain Model/Data Set into logical Resources
  3. Name the resources using URIs i.e. /orders, /orders/{key}, etc.
  4. Expose your subset of the uniform interface i.e. GET/POST/PUT/DELETE
  5. Design the Resource Representations
  6. Design the Hypermedia Resource Representations integration
  7. Design Scenarios, Alternative Paths & Error Conditions   
posted on Tuesday, March 15, 2011 8:25:37 PM UTC  #    Comments [0]
# Saturday, March 05, 2011

Navigate to The Accounting Engine

image

Fill and submit the Request

image

Make sure to have a valid email. 

image

The email will contain among other information a link to the Subscription where you will complete the registration.

image

Complete and submit the Subscription

image

After the Accounting Data is created a logon is displayed

image

Use the information from the email sent to login

image

When you login successfully as an Administrator you will be redirected to the Settings.

posted on Saturday, March 05, 2011 5:23:05 PM UTC  #    Comments [0]
# Thursday, March 03, 2011

Update: This situation has been resolved

Back on October last year I got an email from Microsoft in which they said that they were trying to charge my company credit card for services I was not receiving. I responded:

image

They ignored my request and continued sending the same stupid message only changing the Notice # and I continued replaying:

image

I consider this a harassment and that Microsoft is trying to damage my company reputation and credit history.

If they continue this path I will take legal action to stop this Character Assassination attempt!

posted on Thursday, March 03, 2011 8:49:00 PM UTC  #    Comments [0]
# Thursday, August 19, 2010

Today after downloading and installing Crystal Reports for Visual Studio 2010 Beta 2 I got this message:

CRforVS2010_Beta2

I understand that it is a beta but do they test this stuff!

I am lucky that I always install these kind of software in a test system but it is annoying and time consuming. 

posted on Thursday, August 19, 2010 1:55:19 PM UTC  #    Comments [0]
# Thursday, August 05, 2010

image

 

Can someone from Microsoft explain What is the job of their "Dirteam"?

This is the response I got so far. Is this arrogance or what?:

image

posted on Thursday, August 05, 2010 3:14:54 PM UTC  #    Comments [0]
# Saturday, July 10, 2010

I don't know when and how it happened, maybe when I installed VS 2010 side-by-side with VS 2008, but my VS 2010 default language was set to Visual Basic and I don't use "that thing" anymore. I ignored it for a while since I have been just converting from VS 2008 but it got annoying because every time I created a new project it was created with Visual Basic so I had to delete it and recreate it.

Finally I decided to change the setting but I was looking on the wrong place Tools -> Options. After a while I found this eggheadcafe posting and as it said it is Tools -> Import and Export Settings.:

image

Save your current settings in case you change your mind later: (not me :-))

image

Then select Visual C# Development Settings and click Finish:

image

posted on Saturday, July 10, 2010 6:32:56 PM UTC  #    Comments [0]