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,764 times
Add to favorites
8/16/2012
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
@using System.Web.Http
@using ContactManager.Areas.HelpPage.Models
@model HelpPageApiModel

@{ 
    var description = Model.ApiDescription;
    bool hasParameters = description.ParameterDescriptions.Count > 0;
    bool hasRequestSamples = Model.SampleRequests.Count > 0;
    bool hasResponseSamples = Model.SampleResponses.Count > 0;
}
<h1>@description.HttpMethod.Method @description.RelativePath</h1>
<div>
    @if (description.Documentation != null)
    {
        <p>@description.Documentation</p>
    }
    else
    {
        <p>No documentation available.</p>
    }

    @if (hasParameters || hasRequestSamples)
    {
        <h2>Request Information</h2>
        if (hasParameters)
        {
            <h3>Parameters</h3>
            @Html.DisplayFor(apiModel => apiModel.ApiDescription.ParameterDescriptions, "Parameters")
        }
        if (hasRequestSamples)
        {
            <h3>Request body formats</h3>
            @Html.DisplayFor(apiModel => apiModel.SampleRequests, "Samples", new { sampleClass = "request" })
        }
    } 
       
    @if (hasResponseSamples)
    {      
        <h2>Response Information</h2> 
        <h3>Response body formats</h3>
        @Html.DisplayFor(apiModel => apiModel.SampleResponses, "Samples", new { sampleClass = "response" })
    }
</div>    
<br />
@if (HttpContext.Current.IsDebuggingEnabled && Model.ErrorMessages.Count > 0)
{
    foreach (string errorMessage in Model.ErrorMessages)
    {
        <div class="ui-state-highlight ui-corner-all warning-message-container"> 
            <p>
                <span class="ui-icon ui-icon-info warning-message-icon"></span>
                @errorMessage
            </p>
        </div>
    }
}