Wednesday, 26 July 2017

NIIT Developing Windows Azure and Web Services Lab @ home 3 ~ GNIIT HELP

Developing Windows Azure and Web Services Lab @ home 3 Ans 1
Implement the functionality to query the source and destination information of a specific flight by providing the flight number. Start by creating a new Console application project, and use WhereQ extension method of LINQto Entities.


To implement the required functionality, you need to perform the following steps:
1. Browse to the location where you have saved the Exercise 03.zip file.
2. Extract the files.
3. Double-click the Exercise 03 folder.
4. Double-click the BlueYonder.Companion folder.
5. Double-click the BlueYonder.Companion.sin file. The BlueYonder.Companion - Microsoft Visual Studio window displayed.
6. Select FILE—Add—New Project The Add New Project window is displayed.
7. Ensure that the Installed—Visual C# nodes are expanded in the left pane.
8. Select the Windows node in the left pane.
9. Select the Console Application template in the middle pane.
10. Ensure that the framework selected for the project is .NET Framework 4.5
11. Select and replace the existing text in the Name text box with BlueYonder.FlightDetails
12. Click the OK button. The Program.es file is displayed.
13. Ensure that the Solution Explorer window is opened.
14. Right-click the BlueYonder.FlightDetails node, and then select Add Reference The Reference Manager -BlueYonder.FlightDetails dialog box is displayed.
15. Ensure that the Assemblies node is expanded in the left pane.
16. Ensure that the Framework option is selected in the left pane.
17. Type System.Data.Entity in the Search Assemblies combo box.
18. Select the System.Data.Entity option under the Name column in the middle pane.
19. Select the System.Data.Entity check box.
20. Select the Solution node in the left pane.
21. Select the BlueYonder.Entities option under the Name column in the middle pane.
22. Select the BlueYonder.Entities check box.
23. Click the OK button.
24 Right-click the BlueYonder.FlightDetails node, and then select Manage NuGet Packages The BlueYonder.FlightDetails - Manage NuGet Packages dialog box is displayed.
25. Type EntityFramework in the Search Online combo box.
26. Select the EntityFramework option in the middle pane.
27. Click the Install button. The Installing dialog box is displayed for few seconds and closed automatically.
28 Click the Close button to close BlueYonder.FlightDetails - Manage NuGet Packages dialog box.
29. Right-click the BlueYonder.FlightDetails node in the Solution Explorer window, and then select Set as Startup Project
30. Right-click the BlueYonder.FlightDetails node, and then select Add—Class The Add New Item -BlueYonder.FlightDetails dialog box is displayed.
31. Select and replace the existing text in the Name text box with BlueYonderDbContext
32. Click the Add button. The BlueYonderDbContext.es file is displayed.
33. Type the highlighted portions of the following code snippet in the BlueYonderDbContext.es file:
using System;
using System.Collections.Generic;
using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Data.Entity;
 using BlueYonder.Entities;

34. Type the highlighted portions of the following code snippet in the BlueYonderDbContext.es file:
class BlueYonderDbContext: DbContext
{
public BlueYonderDbContext()
 : base(@"Data
Source= Asqlexpress;Database=BlueYonder .Companion.Lab02integrated Security=True;")
{
}
public DbSet<Location> Locations { get; set; }
public DbSet<Flight> Flights { get; set; }
public DbSet<FlightSchedule> FlightSchedules { get; set; }
public DbSet<Traveler> Travelers { get; set; }
public DbSet<Reservation> Reservations { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<FlightSchedule>()
.HasRequired(fs => fs.Flight)
.WithMany(f => f.Schedules)
.Map(m => m.MapKeyC'FlightlD")); modelBuilder.Entity<Reservation>()
.HasRequired(r => r.DepartureFlight)
.WithManyQ
.HasForeignKey(r => r.DepartFlightSchedulelD); modelBuilder.Entity<Reservation>()
.HasOptional(r => r.ReturnFlight)
.WithManyQ
.HasForeignKey(r => r.ReturnFlightSchedulelD);
}
}
35. Ensure that the Solution Explorer window is opened
36. Double-click the Program.es file.
37. Type the highlighted portions of the following code snippet in the Program.es file:
static void Main(string[] args)
{
BlueYonderDbContext bdbc = new BlueYonderObContext() ;
 Console.WriteLine("Please enter the Flight Number:");
 string flightNumber = Console.ReadLine();
var flightDetails = bdbc.Flights.Where(f => f.FlightNumber == flightNumber) .FirstOrDefault();
if (flightDetails != null)
{
Console.WriteLine("The flight starts from " + flightDetails.Source.Ci ”, " + flightDetails.Source.Country + " for " + flightDetails.Destination.City + ", " flightDetails.Destination.Country + ".");
}
else
{
Console.WriteLine("Invalid Flight Number.");
}
Console.WriteLine("\nPress the ENTER key to close the application.") Console. ReadLineQ;
}
38. Select FILE—Save All to save the changes.
39. Press the F5 key to run the application. The Console window is displayed.
40. Type BY001 in the Console window, and then press the Enter key. The flight details is displayed.
41. Press the Enter key to close the application.
42. Close Microsoft Visual Studio 2012.
Console.WriteLine("Invalid Flight Number.");
}





Developing Windows Azure and Web Services Lab @ home 3 Ans 2


Modify the BlueYonder.FlightDetails project to allow users to update the schedule departure of specific flight.


To implement the required functionality, you need to perform the following tasks:
1. Browse to the location where the Exercise 04.zip file is saved.
2. Extract the files.
3. Double-click the Exercise 04 folder.
4. Double-click the BlueYonder.Companion folder.
5. Double-click the BlueYonder.Companion.sin file. The BlueYonder.Companion - Microsoft Visual Studio window displayed.
6. Ensure that the Solution Explorer window is opened.
7. Ensure that the BlueYonder.FlightDetails node is expanded.
8. Double-click the Program.es file within the BlueYonder.FlightDetails node. The Program.es file is displayed.
9. Type the highlighted portions of the following code snippet in the Program.es file:
if (flightDetails != null)
{
Console.WriteLine("The flight starts from " + flightDetails.Source.City H ”, " + flightDetails.Source.Country + " for " + flightDetails.Destination.City + ”, " + flightDetails.Destination.Country +
}
else
{
Console.WriteLine("Invalid Flight Number.");
>
Console.WriteLine("\nDo you want to update the Flight Schedule? Enter Yes or
No");
string ans = Console.ReadLine(); if (ans.ToLower() == "yes")
{
Console.WriteLine("Enter the date in the MM/DD/YYYY format:"); string date = Console.ReadLine();
Console.WriteLine("Enter the time in the HH:MM:SS format:");
string time = Console.ReadLineQ;
string dateTime = date + " " + time;
foreach (var item in flightDetails.Schedules)
{
item.Departure = Convert.ToDateTime(dateTime)j bdbc .SaveChangesQi
}
Console.WriteLine("\nFlight Schedule is updated")$
}
Console.WriteLine("\nPress the ENTER key to close the application.") Console .ReadLineQ ;
10. Select FILE—Save All to save the changes
11. Select TEST—Windows—Test Explorer The Test Explorer window is displayed
12. Click Run All, and then wait for all the tests to complete.
13. Press the F5 key The output is displayed,
14. Enter a flight number, and then press the Enter key. The details of the specified flight is displayed.
15. Enter Yes. and then press the Enter key to update the flight schedule.
16. Enter the date in the specified format, and then press the Enter key.
17. Enter the time in the specified format, and then press the Enter key. The flight schedule is updated.
18. Press the Enter key to close the Console window.
19. Open SQL Server Management Studio, and connect to the ASQLExpress database server.
20. Expand the Databases node in the Object Explorer window, and then expand the BlueYonder.Companion.Lab02
database.
21. Expand the Tables nodes.
22. Right-click the FlightSchedules table, and then select Select Top 1000 Rows. The FlightSchedules table is displayed with updated record.
23. Close the SQL Server Management window.
24. Switch to Microsoft Visual Studio 2012, and close it.

No comments:

Post a Comment