Pages

Thursday, 5 June 2014

In this article we are going to see how to call a MVC web api from the Rest client, For do this first we have to create a MVC Web API with following HTTP methods GET, POST, PUT, DELETE

In the Following code we are taking a 4 GET methods
1 with returning a Complex object ,
1 which takes id as input and return the corresponding Student. along with url because id is mention in route config.
1 which takes name as input, values are submitted in query string.
1 which takes name , id as input, so one value is mapped in url, another one in Query string.

In the Rest client three things are important
1. Url passing for request along with methods selected.
2. Passing the header information and Body information
3. Content Type selection

In our sample Content-Type is application/json , we will use the Body section on the POST method.

For the various Get Methods:Default Get Methodurl : http://localhost:53986/api/StudentGet with parameter paramter id:url : http://localhost:53986/api/Student/1parameter name:url : http://localhost:53986/api/Student?name=rajesh

In this post content we have to pass a complex object which is a list,now we are going to see how to pass a complex object for rest client.For object we have to use {}For array or List we have to use []then next thing we have to place the property name as key in the left side with in double quotes and value in the right side of colon , string are mention in double quotes values , integer are as it is.For example :*************Array or list of string to pass as a input to API then. ["Rajesh","suresh"]. If an object is need to be pass then { "Name":"Rajesh","Age":10}if an property is an array of another object then"submarks" : [ {"Mark":80,"subject":"Computer"},{"Mark":97,"subject":"Electronic"} ]POST content :[ { "Id" : 1, "Name" : "Rajesh", "Age" : 12, "Subjects" : ["Computer","Electronics"], "Depart" : { "Name":"Computer Science","Id" :1 }, "SubMarks" : [{ "SubectName":"Computer", "Mark":95 }, { "SubectName":"Electronics","Mark":84} ], "Rank" : 13 },{ "Id" : 2, "Name" : "Suresh", "Age" : 8, "Subjects" : ["Computer","Electronics"], "Depart" : { "Name":"Computer Science","Id":1 }, "SubMarks" : [{"SubectName":"Computer","Mark":100},{"SubectName":"Electronics","Mark":100} ], "Rank" : 1 }]Output:

DELETE methodurl : http://localhost:53986/api/Student/1

PUT Method url : http://localhost:53986/api/Student/1

From this article you can learn how to call the MVC web api from the rest client.

Tuesday, 3 June 2014

In this article we are going to see how to create a customize scrollbar in WPF, for that first we have to understand about the Scrollbar, scrollbar is made up with a Track, Two RepeatButtons, and a Thumb.
now we are going to create a Style for each one.

Thumb: For thumb we have to make border with curve
Repeat Buttons: Make the Visible as Transparent
Track : Make a gradient pathResource: