Contact Manager Web API

This sample uses ASP.NET Web API to build a simple contact manager application. The application consists of a contact manager web API that is used by an ASP.NET MVC application, a Windows Phone application, and a Windows 8 app to display and manage a list of contacts.

C# (1.9 MB)
 
 
 
 
 
4.4 Star
(37)
93,806 times
Add to favorites
8/16/2012
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
@using System.Collections.ObjectModel
@using System.Web.Http.Description
@using System.Threading
@model Collection<ApiParameterDescription>

<table>
    <thead class="ui-widget-header">
    <tr><th>Name</th><th>Description</th><th>Additional information</th></tr>
    </thead>
    <tbody class="ui-widget-content">
    @foreach (ApiParameterDescription parameter in Model)
    {
        string parameterDocumentation = parameter.Documentation != null ?
            parameter.Documentation :
            "No documentation available.";
    
        // Don't show CancellationToken because it's a special parameter
        if (!typeof(CancellationToken).IsAssignableFrom(parameter.ParameterDescriptor.ParameterType))
        {
            <tr>
                <td><b>@parameter.Name</b></td>
                <td><pre>@parameterDocumentation</pre></td>
                <td>
                    @switch (parameter.Source)
                    {
                        case ApiParameterSource.FromBody:
                            <p>Define this parameter in the request <b>body</b>.</p>
                            break;
                        case ApiParameterSource.FromUri:
                            <p>Define this parameter in the request <b>URI</b>.</p>
                            break;
                        case ApiParameterSource.Unknown:
                        default:
                            <p>None.</p>
                            break;
                    }
                </td>
            </tr>
        }
    }
    </tbody>
</table>