1. Trang chủ
  2. » Ngoại Ngữ

Moving to Microsoft Visual Studio 2010

100 12 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 100
Dung lượng 8 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

ASP.NET MVC 2.0 Users Browser JQuery Ajax View Controller Model.. Plan My Night Application{[r]

Trang 2

©

Trang 7

MEF Addin

Trang 8

IIS 7.5 ASP.NET 4.0

Trang 11

Contract Interfaces

Trang 12

Trang 21

<Property Name="City" Type="varchar" MaxLength="500" />

<Property Name="State" Type="varchar" MaxLength="500" />

<Property Name="PreferredActivityTypeId" Type="int" />

</EntityType>

Trang 22

<EntitySet Name="UserProfile" EntityType="Entities.Store.UserProfile" store:Type="Views" store:Schema="dbo" store:Name="UserProfile">

</DefiningQuery>

</EntitySet>

Trang 34

namespace Microsoft.Samples.PlanMyNight.Data {

public partial class ZipCode

{

#region Primitive Properties

public virtual string Code

Trang 35

string inputFile = @"PlanMyNight.edmx";

string inputFile = @" \ \PlanMyNight.Data\PlanMyNight.edmx";

Trang 37

var query = from itinerary in ctx.Itineraries.Include("Activities")

where itinerary.Activities.Any(t => t.ActivityId == activityId) && itinerary.IsPublic

Trang 38

var query = from itinerary in ctx.Itineraries.Include("Activities")

where itinerary.Activities.Any(t => t.TypeId == activityTypeId && t.Zip == zip)

Trang 39

public PagingResult<Itinerary> SearchByRadius(int activityTypeId, double longitude, double latitude, double radius, int pageSize, int pageNumber)

{

using (var ctx = new PlanMyNightEntities())

{

ctx.ContextOptions.ProxyCreationEnabled = false;

// Stored Procedure with output parameter

var totalOutput = new ObjectParameter("total", typeof(int));

var items = ctx.RetrieveItinerariesWithinArea(activityTypeId, latitude,

longitude, radius, pageSize, pageNumber, totalOutput).ToArray();

foreach (var item in items)

Trang 40

public void PopulateItineraryActivities(Itinerary itinerary)

Trang 41

Bing Map servicesSQL Server

Application / Web Tier

Data Tier

Trang 42

Application / Web Tier

Data Tier

Bing Map servicesSQL Server

AppFabric Cache Tier

Server NServer 1 Server 2

Trang 44

Trang 45

Trang 46

Trang 47

Trang 48

public class AccountController : Controller {

//

// GET: /Account/

Trang 49

public ActionResult Index()

private readonly IWindowsLiveLogin windowsLogin;

private readonly IMembershipService membershipService; private readonly IFormsAuthentication formsAuthentication; private readonly IReferenceRepository referenceRepository; private readonly IActivitiesRepository activitiesRepository;

Trang 51

public ActionResult LiveId()

Trang 52

var returnUrl = liveIdUser.Context;

var userId = new Guid(liveIdUser.Id).ToString();

profile.State = string.Empty;

profile.City = string.Empty;

profile.PreferredActivityTypeId = 0;

this.membershipService.UpdateProfile(profile);

if (string.IsNullOrEmpty(returnUrl)) returnUrl = null;

return RedirectToAction("Index", new { returnUrl = returnUrl }); }

Trang 53

<system.web>

<profile enabled="true">

<properties>

<add name="FullName" type="string" />

<add name="State" type="string" />

<add name="City" type="string" />

<add name="PreferredActivityTypeId" type="int" />

Trang 54

this.windowsLogin.GetClearCookieResponse(out type, out content);

return new FileStreamResult(new MemoryStream(content), type);

var returnUrl = liveIdUser.Context;

var userId = new Guid(liveIdUser.Id).ToString();

profile.State = string.Empty;

profile.City = string.Empty;

profile.PreferredActivityTypeId = 0;

this.membershipService.UpdateProfile(profile);

if (string.IsNullOrEmpty(returnUrl)) returnUrl = null;

return RedirectToAction("Index", new { returnUrl = returnUrl }); }

Trang 55

public ActionResult Login(string returnUrl)

var profile = this.membershipService.GetCurrentProfile();

var model = new ProfileViewModel

Trang 57

private void InjectStatesAndActivityTypes(ProfileViewModel model)

{

var profile = model.Profile;

var types = this.activitiesRepository.RetrieveActivityTypes().Select(

types.Insert(0, new SelectListItem { Text = "Select ", Value = "0" }); var states = this.referenceRepository.RetrieveStates().Select(

states.Insert(0, new SelectListItem {

Text = "Any state",

}

Trang 59

[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]

public class AccountController : Controller

{

private readonly IWindowsLiveLogin windowsLogin;

private readonly IMembershipService membershipService;

private readonly IFormsAuthentication formsAuthentication;

private readonly IReferenceRepository referenceRepository;

private readonly IActivitiesRepository activitiesRepository; public AccountController() :

}

public AccountController(IMembershipService membershipService, IWindowsLiveLogin windowsLogin,

IFormsAuthentication formsAuthentication, IReferenceRepository referenceRepository, IActivitiesRepository activitiesRepository) {

Trang 60

var liveIdUser = this.windowsLogin.ProcessLogin(tokenContext);

if (liveIdUser != null)

{

var returnUrl = liveIdUser.Context;

var userId = new Guid(liveIdUser.Id).ToString();

if (!this.membershipService.ValidateUser(userId, userId)) {

Trang 61

var profile = this.membershipService.GetCurrentProfile();

var model = new ProfileViewModel

new JsonResult { JsonRequestBehavior =

JsonRequestBehavior.AllowGet, Data = ModelState }

Update = true,

Profile = profile,

ReturnUrl = returnUrl } };

}

Trang 62

var profile = model.Profile;

var types = this.activitiesRepository.RetrieveActivityTypes()

Select(o => new SelectListItem { Text = o.Name, Value = o.Id.ToString(),

Selected = (profile != null &&

o.Id == profile.PreferredActivityTypeId) })

.ToList();

types.Insert(0, new SelectListItem { Text = "Select ", Value = "0" });

var states = this.referenceRepository.RetrieveStates().Select(

Trang 64

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Plan My Night - Profile

Url.Content("~/Content/Scripts/MicrosoftMvcJQueryValidation.js"), "pmn"); %> <% Ajax.RegisterCombinedScriptInclude(

Url.Content("~/Content/Scripts/ajax.common.js"), "pmn"); %>

<% Ajax.RegisterCombinedScriptInclude(

Url.Content("~/Content/Scripts/ajax.profile.js"), "pmn"); %>

Trang 65

<%= Ajax.RenderClientScripts() %>

</asp:Content>

<asp:Content ContentPlaceHolderID="MainContent" runat="server">

<div class="panel" id="profileForm">

Trang 67

<asp:Content ContentPlaceHolderID="TitleContent" runat="server">Plan My Night - Profile Updated</asp:Content>

<asp:Content ContentPlaceHolderID="MainContent" runat="server">

<div class="panel" id="profileForm">

Trang 68

</div>

</asp:Content>

Trang 72

<h2><span>Error Feedback</span></h2>

Trang 75

[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}

or <a href=”/ErrorFeedback.aspx”>send feedback</a>?

Trang 76

protected void Page_Load(object sender, EventArgs e) {

if (this.IsPostBack && this.IsValid) {

this.Response.Redirect("/", true); }

}

Trang 80

// MEF Controller factory

var controllerFactory = new MefControllerFactory(container);

ControllerBuilder.Current.SetControllerFactory(controllerFactory);

// Register routes from Addins

foreach (RouteCollection routes in container.GetExportedValues<RouteCollection>())

// get addin links and toolboxes

var addinBoxes = new List<RouteValueDictionary>();

var addinLinks = new List<ExtensionLink>();

addinBoxes.AddRange(AddinExtensions.GetActionsFor("ItineraryToolbox", model.Id == 0 ? null : new { id = model.Id }));

Trang 81

addinLinks.AddRange(AddinExtensions.GetLinksFor("ItineraryLinks", model.Id == 0 ? null : new { id = model.Id }));

Trang 82

Trang 87

var authority var pathAndQuery.

Trang 97

int totalMinutes = 0; // TODO: Initialize to an appropriate value

string expected = string.Empty; // TODO: Initialize to an appropriate value

string actual;

actual = TimeHelper.GetFriendlyTime(totalMinutes);

Assert.AreEqual(expected, actual);

Assert.Inconclusive("Verify the correctness of this test method.");

Trang 98

public void MoreThan60MinutesReturnsValueInHoursAndMinutes()

{

Assert.AreEqual("2h 3m", TimeHelper.GetFriendlyTime(123));

}

public class TimeHelperTest Then you

Ngày đăng: 01/04/2021, 12:46

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w