Normalise trailing whitespace and line endings everywhere
This commit is contained in:
Родитель
c425137423
Коммит
74cac774f8
|
@ -13,7 +13,7 @@
|
|||
*.png binary
|
||||
*.gif binary
|
||||
|
||||
*.cs text=auto diff=csharp
|
||||
*.cs text=auto diff=csharp
|
||||
*.vb text=auto
|
||||
*.resx text=auto
|
||||
*.c text=auto
|
||||
|
@ -48,4 +48,4 @@
|
|||
*.fsproj text=auto
|
||||
*.dbproj text=auto
|
||||
*.sln text=auto eol=crlf
|
||||
*.sh eol=lf
|
||||
*.sh eol=lf
|
||||
|
|
|
@ -17,4 +17,4 @@ os:
|
|||
- osx
|
||||
osx_image: xcode7.1
|
||||
script:
|
||||
- ./build.sh verify
|
||||
- ./build.sh verify
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
<add key="AspNetVNext" value="https://www.myget.org/f/aspnetmaster/api/v3/index.json" />
|
||||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
</configuration>
|
||||
|
|
|
@ -91,7 +91,7 @@ Note that to run the React example, you'll also need to run `webpack` from the `
|
|||
```
|
||||
|
||||
4. Where applicable, build the project. For example, the Angular example uses Gulp, so you'll need to execute `gulp`, whereas the React example uses Webpack, so you'll need to execute `webpack`. The ES2015 example does not need to be built.
|
||||
|
||||
|
||||
If you don't already have it, install the applicable build tool first (e.g., `npm install -g webpack`).
|
||||
|
||||
5. Run the project (and wait until it displays the message `Application started`)
|
||||
|
|
|
@ -4,4 +4,4 @@ build_script:
|
|||
- build.cmd verify
|
||||
clone_depth: 1
|
||||
test: off
|
||||
deploy: off
|
||||
deploy: off
|
||||
|
|
|
@ -27,4 +27,4 @@ namespace MusicStore.Apis
|
|||
return Json(artists);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,4 +67,4 @@ namespace MusicStore.Apis
|
|||
return Json(albums);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,4 +60,4 @@ namespace MusicStore.Models
|
|||
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace MusicStore.Models
|
|||
{
|
||||
public Album()
|
||||
{
|
||||
// TODO: Temporary hack to populate the orderdetails until EF does this automatically.
|
||||
// TODO: Temporary hack to populate the orderdetails until EF does this automatically.
|
||||
OrderDetails = new List<OrderDetail>();
|
||||
}
|
||||
|
||||
|
@ -37,4 +37,4 @@ namespace MusicStore.Models
|
|||
|
||||
public virtual ICollection<OrderDetail> OrderDetails { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,4 +9,4 @@ namespace MusicStore.Models
|
|||
[Required]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,4 +18,4 @@ namespace MusicStore.Models
|
|||
|
||||
public virtual Album Album { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,4 +21,4 @@ namespace MusicStore.Models
|
|||
[JsonIgnore]
|
||||
public virtual ICollection<Album> Albums { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,4 +31,4 @@ namespace MusicStore.Models
|
|||
base.OnModelCreating(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,4 +70,4 @@ namespace MusicStore.Models
|
|||
|
||||
public ICollection<OrderDetail> OrderDetails { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,4 +11,4 @@
|
|||
public virtual Album Album { get; set; }
|
||||
public virtual Order Order { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,13 +42,13 @@ namespace MusicStore.Models
|
|||
{
|
||||
// Query in a separate context so that we can attach existing entities as modified
|
||||
List<TEntity> existingData;
|
||||
|
||||
|
||||
using (var scope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
|
||||
using (var db = scope.ServiceProvider.GetService<MusicStoreContext>())
|
||||
{
|
||||
existingData = db.Set<TEntity>().ToList();
|
||||
}
|
||||
|
||||
|
||||
using (var scope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
|
||||
using (var db = scope.ServiceProvider.GetService<MusicStoreContext>())
|
||||
{
|
||||
|
@ -65,8 +65,8 @@ namespace MusicStore.Models
|
|||
|
||||
private static Album[] GetAlbums(string imgUrl, Dictionary<string, Genre> genres, Dictionary<string, Artist> artists)
|
||||
{
|
||||
var albums = new Album[]
|
||||
{
|
||||
var albums = new Album[]
|
||||
{
|
||||
new Album { Title = "The Best Of The Men At Work", Genre = genres["Pop"], Price = 8.99M, Artist = artists["Men At Work"], AlbumArtUrl = imgUrl },
|
||||
new Album { Title = "...And Justice For All", Genre = genres["Metal"], Price = 8.99M, Artist = artists["Metallica"], AlbumArtUrl = imgUrl },
|
||||
new Album { Title = "עד גבול האור", Genre = genres["World"], Price = 8.99M, Artist = artists["אריק אינשטיין"], AlbumArtUrl = imgUrl },
|
||||
|
@ -912,4 +912,4 @@ namespace MusicStore.Models
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ namespace MusicStore.Models
|
|||
public static class SentimentAnalysis
|
||||
{
|
||||
private static string[] positiveSentimentWords = new[] { "happy", "fun", "joy", "love", "delight", "bunny", "bunnies", "asp.net" };
|
||||
|
||||
|
||||
private static string[] negativeSentimentWords = new[] { "sad", "pain", "despair", "hate", "scorn", "death", "package management" };
|
||||
|
||||
|
||||
public static SentimentResult GetSentiment(string text) {
|
||||
var numPositiveWords = CountWordOccurrences(text, positiveSentimentWords);
|
||||
var numNegativeWords = CountWordOccurrences(text, negativeSentimentWords);
|
||||
|
@ -35,4 +35,4 @@ namespace MusicStore.Models
|
|||
Positive,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace MusicStore.Models
|
|||
|
||||
public decimal GetTotal()
|
||||
{
|
||||
// Multiply album price by count of that album to get
|
||||
// Multiply album price by count of that album to get
|
||||
// the current price for each of those albums in the cart
|
||||
// sum all album price totals to get the cart total
|
||||
|
||||
|
@ -190,7 +190,7 @@ namespace MusicStore.Models
|
|||
|
||||
if (string.IsNullOrWhiteSpace(sessionCookie))
|
||||
{
|
||||
//A GUID to hold the cartId.
|
||||
//A GUID to hold the cartId.
|
||||
cartId = Guid.NewGuid().ToString();
|
||||
|
||||
// Send cart Id as a cookie to the client.
|
||||
|
@ -204,4 +204,4 @@ namespace MusicStore.Models
|
|||
return cartId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,4 +16,4 @@ namespace MusicStore.Infrastructure
|
|||
base.OnResultExecuting(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,4 +147,4 @@ namespace MusicStore.Infrastructure
|
|||
public int PageSize { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,4 +16,4 @@
|
|||
<DevelopmentServerPort>5068</DevelopmentServerPort>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace MusicStore
|
|||
// Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
|
||||
// You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
|
||||
// services.AddWebApiConventions();
|
||||
|
||||
|
||||
// Add EF services to the service container
|
||||
services.AddEntityFramework()
|
||||
.AddSqlite()
|
||||
|
@ -82,7 +82,7 @@ namespace MusicStore
|
|||
{
|
||||
// Initialize the sample data
|
||||
SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
|
||||
|
||||
|
||||
loggerFactory.MinimumLevel = LogLevel.Warning;
|
||||
loggerFactory.AddConsole();
|
||||
loggerFactory.AddDebug();
|
||||
|
@ -103,7 +103,7 @@ namespace MusicStore
|
|||
// send the request to the following path or controller action.
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
|
||||
|
||||
// Add static files to the request pipeline.
|
||||
app.UseStaticFiles();
|
||||
|
||||
|
@ -112,7 +112,7 @@ namespace MusicStore
|
|||
{
|
||||
// Matches requests that correspond to an existent controller/action pair
|
||||
routes.MapRoute("default", "{controller}/{action}/{id:int?}");
|
||||
|
||||
|
||||
// Matches any other request that doesn't appear to have a filename extension (defined as 'having a dot in the last URI segment').
|
||||
// This means you'll correctly get 404s for /some/dir/non-existent-image.png instead of returning the SPA HTML.
|
||||
// However, it means requests like /customers/isaac.newton will *not* be mapped into the SPA, so if you need to accept
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<cache vary-by="@Context.Request.Path">
|
||||
<app asp-ng2-prerender-module="wwwroot/ng-app/components/app/app">
|
||||
Loading...
|
||||
</app>
|
||||
</cache>
|
||||
|
||||
@section scripts {
|
||||
@await Html.PrimeCache(Url.Action("GenreMenuList", "GenresApi"))
|
||||
@await Html.PrimeCache(Url.Action("MostPopular", "AlbumsApi"))
|
||||
|
||||
<script src="~/lib/angular2/bundles/angular2-polyfills.js"></script>
|
||||
<script src="~/lib/traceur/bin/traceur-runtime.js"></script>
|
||||
<script src="~/lib/es6-module-loader/dist/es6-module-loader-sans-promises.js"></script>
|
||||
<script src="~/lib/systemjs/dist/system.src.js"></script>
|
||||
<script src="~/system.config.js"></script>
|
||||
<script src="~/lib/rxjs/bundles/Rx.js"></script>
|
||||
<script src="~/lib/angular2/bundles/angular2.dev.js"></script>
|
||||
<script src="~/lib/angular2/bundles/router.dev.js"></script>
|
||||
<script src="~/lib/angular2/bundles/http.dev.js"></script>
|
||||
<script src="~/lib/angular2-aspnet/bundles/angular2-aspnet.js"></script>
|
||||
<script>System.import('./ng-app/components/app/bootstrap');</script>
|
||||
}
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<cache vary-by="@Context.Request.Path">
|
||||
<app asp-ng2-prerender-module="wwwroot/ng-app/components/app/app">
|
||||
Loading...
|
||||
</app>
|
||||
</cache>
|
||||
|
||||
@section scripts {
|
||||
@await Html.PrimeCache(Url.Action("GenreMenuList", "GenresApi"))
|
||||
@await Html.PrimeCache(Url.Action("MostPopular", "AlbumsApi"))
|
||||
|
||||
<script src="~/lib/angular2/bundles/angular2-polyfills.js"></script>
|
||||
<script src="~/lib/traceur/bin/traceur-runtime.js"></script>
|
||||
<script src="~/lib/es6-module-loader/dist/es6-module-loader-sans-promises.js"></script>
|
||||
<script src="~/lib/systemjs/dist/system.src.js"></script>
|
||||
<script src="~/system.config.js"></script>
|
||||
<script src="~/lib/rxjs/bundles/Rx.js"></script>
|
||||
<script src="~/lib/angular2/bundles/angular2.dev.js"></script>
|
||||
<script src="~/lib/angular2/bundles/router.dev.js"></script>
|
||||
<script src="~/lib/angular2/bundles/http.dev.js"></script>
|
||||
<script src="~/lib/angular2-aspnet/bundles/angular2-aspnet.js"></script>
|
||||
<script>System.import('./ng-app/components/app/bootstrap');</script>
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
<!doctype html>
|
||||
<html lang="">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Music Store</title>
|
||||
<base href="/" />
|
||||
|
||||
<environment names="Development">
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" />
|
||||
</environment>
|
||||
<environment names="Staging,Production">
|
||||
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.0.0/css/bootstrap.min.css"
|
||||
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
|
||||
asp-fallback-test-class="hidden" asp-fallback-test-property="visibility" asp-fallback-test-value="hidden" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
</environment>
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
|
||||
<environment names="Development">
|
||||
<script src="~/lib/jquery/dist/jquery.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
|
||||
</environment>
|
||||
<environment names="Staging,Production">
|
||||
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"
|
||||
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
|
||||
asp-fallback-test="window.jQuery">
|
||||
</script>
|
||||
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.0.0/bootstrap.min.js"
|
||||
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
|
||||
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal">
|
||||
</script>
|
||||
</environment>
|
||||
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
<!doctype html>
|
||||
<html lang="">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Music Store</title>
|
||||
<base href="/" />
|
||||
|
||||
<environment names="Development">
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" />
|
||||
</environment>
|
||||
<environment names="Staging,Production">
|
||||
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.0.0/css/bootstrap.min.css"
|
||||
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
|
||||
asp-fallback-test-class="hidden" asp-fallback-test-property="visibility" asp-fallback-test-value="hidden" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
</environment>
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
|
||||
<environment names="Development">
|
||||
<script src="~/lib/jquery/dist/jquery.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
|
||||
</environment>
|
||||
<environment names="Staging,Production">
|
||||
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"
|
||||
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
|
||||
asp-fallback-test="window.jQuery">
|
||||
</script>
|
||||
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.0.0/bootstrap.min.js"
|
||||
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
|
||||
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal">
|
||||
</script>
|
||||
</environment>
|
||||
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@using MusicStore
|
||||
@using Microsoft.AspNet.AngularServices
|
||||
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
|
||||
@addTagHelper "*, Microsoft.AspNet.AngularServices"
|
||||
@using MusicStore
|
||||
@using Microsoft.AspNet.AngularServices
|
||||
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
|
||||
@addTagHelper "*, Microsoft.AspNet.AngularServices"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
|
|
|
@ -44,4 +44,4 @@
|
|||
"gulp"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,5 +17,5 @@ import { AlbumEdit } from '../album-edit/album-edit';
|
|||
directives: [router.ROUTER_DIRECTIVES]
|
||||
})
|
||||
export class AdminHome {
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,13 +9,13 @@ import * as models from '../../../models/models';
|
|||
})
|
||||
export class AlbumDeletePrompt {
|
||||
public album: models.Album;
|
||||
|
||||
|
||||
constructor(@ng.Inject(ng.ElementRef) private _elementRef: ng.ElementRef) {
|
||||
}
|
||||
|
||||
|
||||
public show(album: models.Album) {
|
||||
this.album = album;
|
||||
|
||||
|
||||
// Consider rewriting this using Angular 2's "Renderer" API so as to avoid direct DOM access
|
||||
(<any>window).jQuery(".modal", this._elementRef.nativeElement).modal();
|
||||
}
|
||||
|
|
|
@ -47,4 +47,4 @@
|
|||
</div>
|
||||
</form>
|
||||
|
||||
<album-delete-prompt #deleteprompt></album-delete-prompt>
|
||||
<album-delete-prompt #deleteprompt></album-delete-prompt>
|
||||
|
|
|
@ -13,7 +13,7 @@ import { AlbumDeletePrompt } from '../album-delete-prompt/album-delete-prompt';
|
|||
})
|
||||
export class AlbumDetails {
|
||||
public albumData: models.Album;
|
||||
|
||||
|
||||
constructor(http: Http, routeParam: router.RouteParams) {
|
||||
http.get('/api/albums/' + routeParam.params['albumId']).subscribe(result => {
|
||||
this.albumData = result.json();
|
||||
|
|
|
@ -8,18 +8,18 @@
|
|||
<option *ngFor="#artist of artists" [value]="artist.ArtistId">{{ artist.Name }}</option>
|
||||
</select>
|
||||
</form-field>
|
||||
|
||||
|
||||
<form-field label="Genre" [validate]="form.controls.GenreId">
|
||||
<select class="form-control" ngControl="GenreId">
|
||||
<option value="0">-- choose Genre --</option>
|
||||
<option *ngFor="#genre of genres" [value]="genre.GenreId">{{ genre.Name }}</option>
|
||||
</select>
|
||||
</form-field>
|
||||
|
||||
|
||||
<form-field label="Title" [validate]="form.controls.Title">
|
||||
<input class="form-control" type="text" ngControl="Title">
|
||||
</form-field>
|
||||
|
||||
|
||||
<form-field label="Price" [validate]="form.controls.Price">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">$</span>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<form-field label="Album Art URL" [validate]="form.controls.AlbumArtUrl">
|
||||
<input class="form-control" ngControl="AlbumArtUrl">
|
||||
</form-field>
|
||||
|
||||
|
||||
<form-field label="Album Art">
|
||||
<img src="{{ form.controls.AlbumArtUrl.value }}">
|
||||
</form-field>
|
||||
|
@ -44,4 +44,4 @@
|
|||
</form-field>
|
||||
</form>
|
||||
|
||||
<album-delete-prompt #deleteprompt></album-delete-prompt>
|
||||
<album-delete-prompt #deleteprompt></album-delete-prompt>
|
||||
|
|
|
@ -55,7 +55,7 @@ export class AlbumEdit {
|
|||
Price: fb.control('', Validators.compose([Validators.required, AlbumEdit._validatePrice])),
|
||||
AlbumArtUrl: fb.control('', Validators.required)
|
||||
});
|
||||
|
||||
|
||||
this.form.valueChanges.subscribe(() => {
|
||||
this.changesSaved = false;
|
||||
});
|
||||
|
@ -70,7 +70,7 @@ export class AlbumEdit {
|
|||
if (this.form.valid) {
|
||||
var controls = this.form.controls;
|
||||
var albumId = this.originalAlbum.AlbumId;
|
||||
|
||||
|
||||
this._putJson(`/api/albums/${ albumId }/update`, this.form.value).subscribe(successResponse => {
|
||||
this.changesSaved = true;
|
||||
}, errorResponse => {
|
||||
|
@ -82,7 +82,7 @@ export class AlbumEdit {
|
|||
private static _validatePrice(control: Control): { [key: string]: boolean } {
|
||||
return /^\d+\.\d+$/.test(control.value) ? null : { Price: true };
|
||||
}
|
||||
|
||||
|
||||
// Need feedback on whether this really is the easiest way to PUT some JSON
|
||||
private _putJson(url: string, body: any): Observable<Response> {
|
||||
return this._http.put(url, JSON.stringify(body), {
|
||||
|
@ -93,4 +93,4 @@ export class AlbumEdit {
|
|||
private ngDoCheck() {
|
||||
this.formErrors = this.form.dirty ? Object.keys(this.form.errors || {}) : [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<div class="btn-group">
|
||||
<button class="btn btn-default" [disabled]="!canGoBack" (click)="goToPage(1)">First</button>
|
||||
<button class="btn btn-default" [disabled]="!canGoBack" (click)="goToPage(pageIndex - 1)">Previous</button>
|
||||
<button class="btn" *ngFor="#page of pageLinks"
|
||||
<button class="btn" *ngFor="#page of pageLinks"
|
||||
[ngClass]="{ 'btn-info': page.isCurrent, 'btn-default': !page.isCurrent }"
|
||||
(click)="goToPage(page.index)">
|
||||
{{ page.text }}
|
||||
|
|
|
@ -20,7 +20,7 @@ export class AlbumsList {
|
|||
public get pageIndex() {
|
||||
return this._pageIndex;
|
||||
}
|
||||
|
||||
|
||||
private _http: Http;
|
||||
private _pageIndex = 1;
|
||||
private _sortBy = "Title";
|
||||
|
@ -30,28 +30,28 @@ export class AlbumsList {
|
|||
this._http = http;
|
||||
this.refreshData();
|
||||
}
|
||||
|
||||
|
||||
public sortBy(col: string) {
|
||||
this._sortByDesc = col === this._sortBy ? !this._sortByDesc : false;
|
||||
this._sortBy = col;
|
||||
this.refreshData();
|
||||
}
|
||||
|
||||
|
||||
public goToPage(pageIndex: number) {
|
||||
this._pageIndex = pageIndex;
|
||||
this.refreshData();
|
||||
}
|
||||
|
||||
|
||||
public goToLast() {
|
||||
this.goToPage(this.pageLinks[this.pageLinks.length - 1].index);
|
||||
}
|
||||
|
||||
|
||||
refreshData() {
|
||||
var sortBy = this._sortBy + (this._sortByDesc ? ' DESC' : '');
|
||||
this._http.get(`/api/albums?page=${ this._pageIndex }&pageSize=50&sortBy=${ sortBy }`).subscribe(result => {
|
||||
var json = result.json();
|
||||
this.rows = json.Data;
|
||||
|
||||
|
||||
var numPages = Math.ceil(json.TotalCount / json.PageSize);
|
||||
this.pageLinks = [];
|
||||
for (var i = 1; i <= numPages; i++) {
|
||||
|
@ -61,7 +61,7 @@ export class AlbumsList {
|
|||
isCurrent: i === json.Page
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
this.canGoBack = this.pageLinks.length && !this.pageLinks[0].isCurrent;
|
||||
this.canGoForward = this.pageLinks.length && !this.pageLinks[this.pageLinks.length - 1].isCurrent;
|
||||
this.totalCount = json.TotalCount;
|
||||
|
|
|
@ -11,7 +11,7 @@ import { AbstractControl } from 'angular2/common';
|
|||
export class FormField {
|
||||
public errorMessages: string[] = [];
|
||||
private validate: AbstractControl;
|
||||
|
||||
|
||||
private ngDoCheck() {
|
||||
var errors = (this.validate && this.validate.dirty && this.validate.errors) || {};
|
||||
this.errorMessages = Object.keys(errors).map(key => {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<div *ngIf="albumData">
|
||||
<h2>{{ albumData.Title }}</h2>
|
||||
|
||||
|
||||
<p>
|
||||
<img alt="{{ albumData.Title }}" src="{{ albumData.AlbumArtUrl }}">
|
||||
</p>
|
||||
|
||||
|
||||
<div id="album-details">
|
||||
<p>
|
||||
<em>Genre:</em>
|
||||
|
@ -23,4 +23,4 @@
|
|||
Add to cart
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -11,7 +11,7 @@ import * as models from '../../../models/models';
|
|||
})
|
||||
export class AlbumDetails {
|
||||
public albumData: models.Album;
|
||||
|
||||
|
||||
constructor(http: Http, routeParam: router.RouteParams) {
|
||||
http.get('/api/albums/' + routeParam.params['albumId']).subscribe(result => {
|
||||
this.albumData = result.json();
|
||||
|
|
|
@ -16,7 +16,7 @@ export class GenreContents {
|
|||
|
||||
constructor(http: Http, routeParam: router.RouteParams) {
|
||||
http.get(`/api/genres/${ routeParam.params['genreId'] }/albums`).subscribe(result => {
|
||||
this.albums = result.json();
|
||||
this.albums = result.json();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ export class GenresList {
|
|||
|
||||
constructor(http: Http) {
|
||||
http.get('/api/genres').subscribe(result => {
|
||||
this.genres = result.json();
|
||||
this.genres = result.json();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as ng from 'angular2/core';
|
|||
import { Http } from 'angular2/http';
|
||||
import { AlbumTile } from '../album-tile/album-tile';
|
||||
import * as models from '../../../models/models';
|
||||
|
||||
|
||||
@ng.Component({
|
||||
selector: 'home'
|
||||
})
|
||||
|
@ -15,7 +15,7 @@ export class Home {
|
|||
|
||||
constructor(http: Http) {
|
||||
http.get('/api/albums/mostPopular').subscribe(result => {
|
||||
this.mostPopular = result.json();
|
||||
this.mostPopular = result.json();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
|
|
@ -16,4 +16,4 @@
|
|||
<DevelopmentServerPort>2018</DevelopmentServerPort>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -56,23 +56,23 @@ namespace ES2015Example
|
|||
// send the request to the following path or controller action.
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
|
||||
|
||||
// Dynamically transpile any .js files under the '/js/' directory
|
||||
app.Use(next => async context => {
|
||||
var requestPath = context.Request.Path.Value;
|
||||
if (requestPath.StartsWith("/js/") && requestPath.EndsWith(".js")) {
|
||||
var fileInfo = env.WebRootFileProvider.GetFileInfo(requestPath);
|
||||
var fileInfo = env.WebRootFileProvider.GetFileInfo(requestPath);
|
||||
if (fileInfo.Exists) {
|
||||
var transpiled = await nodeServices.Invoke<string>("transpilation.js", fileInfo.PhysicalPath, requestPath);
|
||||
await context.Response.WriteAsync(transpiled);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Not a JS file, or doesn't exist - let some other middleware handle it
|
||||
await next.Invoke(context);
|
||||
});
|
||||
|
||||
|
||||
// Add static files to the request pipeline.
|
||||
app.UseStaticFiles();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Hello
|
||||
|
||||
@section scripts {
|
||||
<script src="lib/system.js"></script>
|
||||
<script>System.import('js/main.js');</script>
|
||||
}
|
||||
Hello
|
||||
|
||||
@section scripts {
|
||||
<script src="lib/system.js"></script>
|
||||
<script>System.import('js/main.js');</script>
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>ES2015 Example</title>
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>ES2015 Example</title>
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
@using ES2015Example
|
||||
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
|
||||
@using ES2015Example
|
||||
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
|
|
|
@ -40,4 +40,4 @@
|
|||
"npm install"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ var babelCore = require('babel-core');
|
|||
|
||||
module.exports = function(cb, physicalPath, requestPath) {
|
||||
var originalContents = fs.readFileSync(physicalPath);
|
||||
var result = babelCore.transform(originalContents, {
|
||||
var result = babelCore.transform(originalContents, {
|
||||
sourceMaps: 'inline',
|
||||
sourceFileName: '/sourcemapped' + requestPath
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace Webpack
|
|||
}
|
||||
|
||||
app.UseIISPlatformHandler();
|
||||
|
||||
|
||||
if (env.IsDevelopment()) {
|
||||
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
|
||||
HotModuleReplacement = true
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<h1>Hello</h1>
|
||||
Hi there. Enter some text: <input />
|
||||
|
||||
@section scripts {
|
||||
<script src="dist/main.js"></script>
|
||||
}
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<h1>Hello</h1>
|
||||
Hi there. Enter some text: <input />
|
||||
|
||||
@section scripts {
|
||||
<script src="dist/main.js"></script>
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>@ViewData["Title"]</title>
|
||||
<environment names="Production">
|
||||
<link rel="stylesheet" href="dist/my-styles.css" />
|
||||
</environment>
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>@ViewData["Title"]</title>
|
||||
<environment names="Production">
|
||||
<link rel="stylesheet" href="dist/my-styles.css" />
|
||||
</environment>
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
@using Webpack
|
||||
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
|
||||
@using Webpack
|
||||
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ module.exports = merge({
|
|||
],
|
||||
},
|
||||
entry: {
|
||||
main: ['./Clientside/App.ts']
|
||||
main: ['./Clientside/App.ts']
|
||||
},
|
||||
output: {
|
||||
path: path.join(__dirname, 'wwwroot', 'dist'),
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = {
|
|||
]
|
||||
},
|
||||
plugins: [
|
||||
extractLESS,
|
||||
extractLESS,
|
||||
new webpack.optimize.UglifyJsPlugin({ minimize: true })
|
||||
]
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
|
|
@ -27,4 +27,4 @@ namespace MusicStore.Apis
|
|||
return Json(artists);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,4 +67,4 @@ namespace MusicStore.Apis
|
|||
return Json(albums);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,4 +60,4 @@ namespace MusicStore.Models
|
|||
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace MusicStore.Models
|
|||
{
|
||||
public Album()
|
||||
{
|
||||
// TODO: Temporary hack to populate the orderdetails until EF does this automatically.
|
||||
// TODO: Temporary hack to populate the orderdetails until EF does this automatically.
|
||||
OrderDetails = new List<OrderDetail>();
|
||||
}
|
||||
|
||||
|
@ -37,4 +37,4 @@ namespace MusicStore.Models
|
|||
|
||||
public virtual ICollection<OrderDetail> OrderDetails { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,4 +9,4 @@ namespace MusicStore.Models
|
|||
[Required]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,4 +18,4 @@ namespace MusicStore.Models
|
|||
|
||||
public virtual Album Album { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,4 +21,4 @@ namespace MusicStore.Models
|
|||
[JsonIgnore]
|
||||
public virtual ICollection<Album> Albums { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,4 +31,4 @@ namespace MusicStore.Models
|
|||
base.OnModelCreating(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,4 +70,4 @@ namespace MusicStore.Models
|
|||
|
||||
public ICollection<OrderDetail> OrderDetails { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,4 +11,4 @@
|
|||
public virtual Album Album { get; set; }
|
||||
public virtual Order Order { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,13 +42,13 @@ namespace MusicStore.Models
|
|||
{
|
||||
// Query in a separate context so that we can attach existing entities as modified
|
||||
List<TEntity> existingData;
|
||||
|
||||
|
||||
using (var scope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
|
||||
using (var db = scope.ServiceProvider.GetService<MusicStoreContext>())
|
||||
{
|
||||
existingData = db.Set<TEntity>().ToList();
|
||||
}
|
||||
|
||||
|
||||
using (var scope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
|
||||
using (var db = scope.ServiceProvider.GetService<MusicStoreContext>())
|
||||
{
|
||||
|
@ -65,8 +65,8 @@ namespace MusicStore.Models
|
|||
|
||||
private static Album[] GetAlbums(string imgUrl, Dictionary<string, Genre> genres, Dictionary<string, Artist> artists)
|
||||
{
|
||||
var albums = new Album[]
|
||||
{
|
||||
var albums = new Album[]
|
||||
{
|
||||
new Album { Title = "The Best Of The Men At Work", Genre = genres["Pop"], Price = 8.99M, Artist = artists["Men At Work"], AlbumArtUrl = imgUrl },
|
||||
new Album { Title = "...And Justice For All", Genre = genres["Metal"], Price = 8.99M, Artist = artists["Metallica"], AlbumArtUrl = imgUrl },
|
||||
new Album { Title = "עד גבול האור", Genre = genres["World"], Price = 8.99M, Artist = artists["אריק אינשטיין"], AlbumArtUrl = imgUrl },
|
||||
|
@ -912,4 +912,4 @@ namespace MusicStore.Models
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace MusicStore.Models
|
|||
|
||||
public decimal GetTotal()
|
||||
{
|
||||
// Multiply album price by count of that album to get
|
||||
// Multiply album price by count of that album to get
|
||||
// the current price for each of those albums in the cart
|
||||
// sum all album price totals to get the cart total
|
||||
|
||||
|
@ -190,7 +190,7 @@ namespace MusicStore.Models
|
|||
|
||||
if (string.IsNullOrWhiteSpace(sessionCookie))
|
||||
{
|
||||
//A GUID to hold the cartId.
|
||||
//A GUID to hold the cartId.
|
||||
cartId = Guid.NewGuid().ToString();
|
||||
|
||||
// Send cart Id as a cookie to the client.
|
||||
|
@ -204,4 +204,4 @@ namespace MusicStore.Models
|
|||
return cartId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,4 +16,4 @@ namespace MusicStore.Infrastructure
|
|||
base.OnResultExecuting(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,4 +147,4 @@ namespace MusicStore.Infrastructure
|
|||
public int PageSize { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ export default function (params: any): Promise<{ html: string }> {
|
|||
const app = (
|
||||
<Provider store={ store }>
|
||||
<RouterContext {...renderProps} />
|
||||
</Provider>
|
||||
</Provider>
|
||||
);
|
||||
|
||||
// Perform an initial render that will cause any async tasks (e.g., data access) to begin
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as React from 'react';
|
||||
import * as React from 'react';
|
||||
import { Navbar, Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
|
||||
import { Link } from 'react-router';
|
||||
import { LinkContainer } from 'react-router-bootstrap';
|
||||
|
@ -25,7 +25,7 @@ class NavMenu extends React.Component<NavMenuProps, void> {
|
|||
{genres.map(genre =>
|
||||
<LinkContainer key={ genre.GenreId } to={ `/genre/${ genre.GenreId }` }>
|
||||
<MenuItem>{ genre.Name }</MenuItem>
|
||||
</LinkContainer>
|
||||
</LinkContainer>
|
||||
)}
|
||||
<MenuItem divider />
|
||||
<LinkContainer to={ '/genres' }><MenuItem>More…</MenuItem></LinkContainer>
|
||||
|
@ -43,7 +43,7 @@ class NavMenu extends React.Component<NavMenuProps, void> {
|
|||
// Selects which part of global state maps to this component, and defines a type for the resulting props
|
||||
const provider = provide(
|
||||
(state: ApplicationState) => state.genreList,
|
||||
GenreList.actionCreators
|
||||
GenreList.actionCreators
|
||||
);
|
||||
type NavMenuProps = typeof provider.allProps;
|
||||
export default provider.connect(NavMenu);
|
||||
|
|
|
@ -22,9 +22,9 @@ class AlbumDetails extends React.Component<AlbumDetailsProps, void> {
|
|||
const albumData = this.props.album;
|
||||
return <div>
|
||||
<h2>{ albumData.Title }</h2>
|
||||
|
||||
|
||||
<p><img alt={ albumData.Title } src={ albumData.AlbumArtUrl } /></p>
|
||||
|
||||
|
||||
<div id="album-details">
|
||||
<p>
|
||||
<em>Genre:</em>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as React from 'react';
|
||||
import * as React from 'react';
|
||||
import { Link } from 'react-router';
|
||||
import { Album } from '../../store/FeaturedAlbums';
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class GenreDetails extends React.Component<GenreDetailsProps, void> {
|
|||
componentWillMount() {
|
||||
this.props.requestGenreDetails(parseInt(this.props.params.genreId));
|
||||
}
|
||||
|
||||
|
||||
componentWillReceiveProps(nextProps: GenreDetailsProps) {
|
||||
this.props.requestGenreDetails(parseInt(nextProps.params.genreId));
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ export default function configureStore(history: HistoryModule.History, initialSt
|
|||
const reduxRouterMiddleware = syncHistory(history);
|
||||
const middlewares = [thunk, reduxRouterMiddleware, typedToPlain];
|
||||
const devToolsExtension = null;//(window as any).devToolsExtension; // If devTools is installed, connect to it
|
||||
|
||||
|
||||
const finalCreateStore = compose(
|
||||
applyMiddleware(...middlewares),
|
||||
devToolsExtension ? devToolsExtension() : f => f
|
||||
|
@ -20,10 +20,10 @@ export default function configureStore(history: HistoryModule.History, initialSt
|
|||
const allReducers = buildRootReducer(Store.reducers);
|
||||
|
||||
const store = finalCreateStore(allReducers, initialState) as Redux.Store;
|
||||
|
||||
|
||||
// Required for replaying actions from devtools to work
|
||||
reduxRouterMiddleware.listenForReplays(store);
|
||||
|
||||
|
||||
// Enable Webpack hot module replacement for reducers
|
||||
if (module.hot) {
|
||||
module.hot.accept('./store', () => {
|
||||
|
|
|
@ -47,7 +47,7 @@ class ReceiveAlbumDetails extends Action {
|
|||
// ACTION CREATORS - These are functions exposed to UI components that will trigger a state transition.
|
||||
// They don't directly mutate state, but they can have external side-effects (such as loading data).
|
||||
|
||||
export const actionCreators = {
|
||||
export const actionCreators = {
|
||||
requestAlbumDetails: (albumId: number): ActionCreator => (dispatch, getState) => {
|
||||
// Only load if it's not already loaded (or currently being loaded)
|
||||
if (albumId !== getState().albumDetails.requestedAlbumId) {
|
||||
|
@ -59,7 +59,7 @@ export const actionCreators = {
|
|||
dispatch(new ReceiveAlbumDetails(album));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
dispatch(new RequestAlbumDetails(albumId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ export const actionCreators = {
|
|||
fetch('/api/albums/mostPopular')
|
||||
.then(results => results.json())
|
||||
.then(albums => dispatch(new ReceiveFeaturedAlbums(albums)));
|
||||
|
||||
|
||||
return dispatch(new RequestFeaturedAlbums());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class ReceiveGenreDetails extends Action {
|
|||
// ACTION CREATORS - These are functions exposed to UI components that will trigger a state transition.
|
||||
// They don't directly mutate state, but they can have external side-effects (such as loading data).
|
||||
|
||||
export const actionCreators = {
|
||||
export const actionCreators = {
|
||||
requestGenreDetails: (genreId: number): ActionCreator => (dispatch, getState) => {
|
||||
// Only load if it's not already loaded (or currently being loaded)
|
||||
if (genreId !== getState().genreDetails.requestedGenreId) {
|
||||
|
@ -44,10 +44,10 @@ export const actionCreators = {
|
|||
.then(albums => {
|
||||
// Only replace state if it's still the most recent request
|
||||
if (genreId === getState().genreDetails.requestedGenreId) {
|
||||
dispatch(new ReceiveGenreDetails(genreId, albums));
|
||||
dispatch(new ReceiveGenreDetails(genreId, albums));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
dispatch(new RequestGenreDetails(genreId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class ReceiveGenresList extends Action {
|
|||
// ACTION CREATORS - These are functions exposed to UI components that will trigger a state transition.
|
||||
// They don't directly mutate state, but they can have external side-effects (such as loading data).
|
||||
|
||||
export const actionCreators = {
|
||||
export const actionCreators = {
|
||||
requestGenresList: (): ActionCreator => (dispatch, getState) => {
|
||||
if (!getState().genreList.isLoaded) {
|
||||
fetch('/api/genres')
|
||||
|
|
|
@ -23,5 +23,5 @@ export const reducers = {
|
|||
};
|
||||
|
||||
// This type can be used as a hint on action creators so that its 'dispatch' and 'getState' params are
|
||||
// correctly typed to match your store.
|
||||
// correctly typed to match your store.
|
||||
export type ActionCreator = ActionCreatorGeneric<ApplicationState>;
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace MusicStore
|
|||
// Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
|
||||
// You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
|
||||
// services.AddWebApiConventions();
|
||||
|
||||
|
||||
// Add EF services to the service container
|
||||
services.AddEntityFramework()
|
||||
.AddSqlite()
|
||||
|
@ -78,7 +78,7 @@ namespace MusicStore
|
|||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||
{
|
||||
loggerFactory.AddConsole(LogLevel.Warning);
|
||||
|
||||
|
||||
// Initialize the sample data
|
||||
SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
|
||||
|
||||
|
@ -89,7 +89,7 @@ namespace MusicStore
|
|||
}
|
||||
|
||||
app.UseIISPlatformHandler();
|
||||
|
||||
|
||||
// In dev mode, the JS/TS/etc is compiled and served dynamically and supports hot replacement.
|
||||
// In production, we assume you've used webpack to emit the prebuilt content to disk.
|
||||
if (env.IsDevelopment()) {
|
||||
|
@ -105,7 +105,7 @@ namespace MusicStore
|
|||
routes.MapRoute(
|
||||
name: "default",
|
||||
template: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
|
||||
routes.MapSpaFallbackRoute(
|
||||
name: "spa-fallback",
|
||||
defaults: new { controller = "Home", action = "Index" });
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<div id="react-app" asp-prerender-module="ReactApp/boot-server"
|
||||
asp-prerender-webpack-config="webpack.config.js"></div>
|
||||
|
||||
@section scripts {
|
||||
<script src="/dist/vendor.bundle.js"></script>
|
||||
<script src="/dist/main.js"></script>
|
||||
}
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<div id="react-app" asp-prerender-module="ReactApp/boot-server"
|
||||
asp-prerender-webpack-config="webpack.config.js"></div>
|
||||
|
||||
@section scripts {
|
||||
<script src="/dist/vendor.bundle.js"></script>
|
||||
<script src="/dist/main.js"></script>
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>@ViewData["Title"]</title>
|
||||
<link rel="stylesheet" href="/dist/main.css" />
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>@ViewData["Title"]</title>
|
||||
<link rel="stylesheet" href="/dist/main.css" />
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
@using MusicStore
|
||||
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
|
||||
@addTagHelper "*, Microsoft.AspNet.SpaServices"
|
||||
@using MusicStore
|
||||
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
|
||||
@addTagHelper "*, Microsoft.AspNet.SpaServices"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
|
|
@ -16,14 +16,14 @@ namespace ReactExample.Controllers
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class PersonDto {
|
||||
public string name { get; set; }
|
||||
public string city { get; set; }
|
||||
public string state { get; set; }
|
||||
public string country { get; set; }
|
||||
public string company { get; set; }
|
||||
|
||||
|
||||
[Range(1, 10)]
|
||||
public int favoriteNumber { get; set; }
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ export default function renderApp (params) {
|
|||
const app = <RouterContext {...renderProps} />;
|
||||
|
||||
// Render it as an HTML string which can be injected into the response
|
||||
const html = renderToString(app);
|
||||
const html = renderToString(app);
|
||||
resolve({ html });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ export class CustomPager extends React.Component {
|
|||
pageChange(event) {
|
||||
this.props.setPage(parseInt(event.target.getAttribute("data-value")));
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
var previous = null;
|
||||
var next = null;
|
||||
|
@ -47,4 +47,4 @@ CustomPager.defaultProps = {
|
|||
nextText: '',
|
||||
previousText: '',
|
||||
currentPage: 0
|
||||
};
|
||||
};
|
||||
|
|
|
@ -8,11 +8,11 @@ export class PersonEditor extends React.Component {
|
|||
super();
|
||||
this.state = { savedChanges: false };
|
||||
}
|
||||
|
||||
|
||||
onChange() {
|
||||
this.setState({ savedChanges: false });
|
||||
}
|
||||
|
||||
|
||||
submit(model, reset, setErrors) {
|
||||
PersonEditor.sendJson('put', `/api/people/${ this.props.params.personId }`, model).then(response => {
|
||||
if (response.ok) {
|
||||
|
@ -23,7 +23,7 @@ export class PersonEditor extends React.Component {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
var personId = parseInt(this.props.params.personId);
|
||||
var person = fakeData.filter(p => p.id === personId)[0];
|
||||
|
@ -46,12 +46,12 @@ export class PersonEditor extends React.Component {
|
|||
</Formsy.Form>
|
||||
</div>;
|
||||
}
|
||||
|
||||
|
||||
static sendJson(method, url, object) {
|
||||
return fetch(url, {
|
||||
method: method,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(object)
|
||||
body: JSON.stringify(object)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import { PersonEditor } from './PersonEditor.jsx';
|
|||
export const routes = <Route>
|
||||
<Route path="/" component={ PeopleGrid } />
|
||||
<Route path="/:pageIndex" component={ PeopleGrid } />
|
||||
<Route path="/edit/:personId" component={ PersonEditor } />
|
||||
<Route path="/edit/:personId" component={ PersonEditor } />
|
||||
</Route>;
|
||||
|
||||
export class ReactApp extends React.Component {
|
||||
|
|
|
@ -16,4 +16,4 @@
|
|||
<DevelopmentServerPort>2311</DevelopmentServerPort>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче