programming4us
programming4us
WEBSITE

Sharepoint 2013 : Overview of Windows Azure for Sharepoint (part 5) - DEVELOPING WINDOWS AZURE APPLICATIONS - Creating a Model

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
3. Creating a Model (MyFirstAzureApp.sln)

Now create a simple model to represent the data (which will be a small set of sales data), and then expose that data as a return value using the default controller. The example uses the default plumbing code as much as possible to keep things straightforward.

1. Right-click the Models folder and select Add ⇒ Class. Name the class Sales and then click Add.

2. Add the following bolded code to the Sales class, which provides you with a small set of properties for your custom Sales object.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyFirstAzureWebAPI.Models
{
public class Sales
{
public string Company { get; set; }
public string FY09Sales { get; set; }
public string FY10Sales { get; set; }
public string FY11Sales { get; set; }

}
}
Now that you’ve created a model (or class), you’ll use this class to create a return List collection object that your Web API service will return in JSON format.

3. Expand the Controllers folder and double-click the ValuesController class.

4. Amend the class with the following bolded code (note these are fictional companies and sales figures).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using MyFirstAzureWebAPI.Models;

namespace MyFirstAzureWebAPI.Controllers
{
public class ValuesController : ApiController
{
// GET api/values
public List<Sales> Get()
{
List<Sales> mySales = new List<Sales>();

mySales.Add(new Sales
{
Company="Contoso",
FY09Sales="$9,020,398,122,332.00",
FY10Sales="$10,111,309,312,998.00",
FY11Sales="$11,033,990,102,443.00"
});

mySales.Add(new Sales
{
Company="Fabrikam",
FY09Sales="$7,332,444,552,112.00",
FY10Sales="$5,019,132,011,668.00",
FY11Sales="$3,889,940,589,901.00"
});

mySales.Add(new Sales
{
Company = "Wingtip",
FY09Sales = "$9,032,522,000,129.00",
FY10Sales = "$9,115,339,990,899.00",
FY11Sales = "$9,001,439,321,666.00"
});

return mySales;

}

...

}
}
The code that you added uses the Sales object to create a List collection object. When you append the Web API URI with "api/values" it will return the three SalesList collection as a JSON formatted object. objects within the
5. Press F6 to build.
6. When you’ve added and successfully compiled the code, press F5 to debug the cloud application. (The solution uses the local cloud emulator to debug the Web API.)
7. When debugging, you’ll see the ASP.NET default page appear (within the 127.0.0.1 domain). When you append the "api/values" path to the URL (as in Figure 12), the Web API service passes back a JSON-formatted object.

FIGURE 12

image

How it Works

The MVC templates are a versatile set of ASP.NET Web templates, and the Web API is a specific template that enables you to easily build REST-based services for Windows Azure. You’ll find that Cloud services (such as REST or WCF-based services) will be important to your cloud development efforts for a number of reasons, such as service reuse or application extensibility. In this exercise, you built a REST API with the scaffolding provided by the MVC templates, and the result was a REST service that returned a JSON object.
The JSON object, shown in the following code (with purely fictional data), reflects the List collection you created in the Get method. In essence, this is a small set of data that is returned to you via the REST service call.
[
{
"Company":"Contoso",
"FY09Sales":"$9,020,398,122,332.00",
"FY10Sales":"$10,111,309,312,998.00",
"FY11Sales":"$11,033,990,102,443.00"
},
{
"Company":"Fabrikam",
"FY09Sales":"$7,332,444,552,112.00",
"FY10Sales":"$5,019,132,011,668.00",
"FY11Sales":"$3,889,940,589,901.00"
},
{
"Company":"Wingtip",
"FY09Sales":"$9,032,522,000,129.00",
"FY10Sales":"$9,115,339,990,899.00",
"FY11Sales":"$9,001,439,321,666.00"
}
]
When deployed, the REST service would behave similarly, except the endpoint would be configured to a production URI (for example, http://myapp.cloudapp.net).

Congratulations! You’ve created your first Windows Azure application; that is, a REST-based Web API that returns JSON data. When you deploy it to a production environment, you can use the REST service from a multitude of clients and process the JSON data within your applications — whether it is SharePoint, Windows Phone, Windows 8, or other device/tablet applications.

Even before you deploy your first application to your Windows Azure account, you can use this REST service locally within the cloud emulator environment with other applications. Although you won’t deploy this application to Windows Azure now , you can right-click the cloud project (MyFirstAzureApp) and select Publish. This invokes the Publish Windows Azure Application dialog, which enables you to walk through a wizard and deploy your application directly to your Windows Azure subscription — which you can then manage within the Windows Azure portal. See Figure 13 for the Start page of the Publish Windows Azure Application wizard.

FIGURE 13

image

At this point, you should at least have a basic understanding of what Windows Azure is, how to set up the Windows Azure development environment, and the types of applications that you can build using Windows Azure. You might now be asking yourself, “Why all the Windows Azure hubbub?” When paired with SharePoint 2013, Windows Azure becomes important in two ways:

  • It is natively integrated within the SharePoint application development and deployment experience — you use Windows Azure to build and deploy cloud-hosted applications.
  • You can also use Windows Azure in the broader cloud application development experience — just like you could use an array of other Web technologies and standards.
Other  
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Customizing Companyweb (part 5) - Adding RemoteApps Links - Add the Web Part to Companyweb
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Customizing Companyweb (part 4) - Adding RemoteApps Links - Register the Web Part as Safe
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Customizing Companyweb (part 3) - Adding RemoteApps Links - Configure RD Web Access
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Customizing Companyweb (part 2) - Adding RemoteApps Links - Add the RD Web Access Role Service
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Customizing Companyweb (part 1) - Adding a Workspace
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Introducing SharePoint Foundation 2010
  •  Sharepoint 2010 : The Search User Interface - The People Search Page (part 3) - Expertise Search, The Preferences Page
  •  Sharepoint 2010 : The Search User Interface - The People Search Page (part 2) - Using People Search Results, Taking Action on Results
  •  Sharepoint 2010 : The Search User Interface - The People Search Page (part 1) - People Search Options
  •  Sharepoint 2010 : The Search User Interface - The Advanced Search Page (part 2) - Picking Property Restrictions
  •  
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us