Skip to content

Commit

Permalink
Correção deletar em cascata e configurações build
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur-Neto committed Aug 31, 2020
1 parent fb1178b commit 2ec831c
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/api/Theater.Application/MoviesModule/MovieService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task<int> CreateAsync(MovieCreateCommand command)

public async Task<bool> DeleteAsync(int id)
{
var movie = await _repository.SingleOrDefaultAsync(x => x.ID == id);
var movie = await _repository.SingleOrDefaultAsync(x => x.ID == id, true, p => p.Sessions);
Guard.Against(movie, ErrorType.NotFound);

await _repository.DeleteAsync(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public void Configure(EntityTypeBuilder<Movie> builder)
builder.Property(u => u.AudioType)
.HasColumnType("smallint")
.IsRequired();

builder.HasMany(p => p.Sessions)
.WithOne(p => p.Movie)
.OnDelete(DeleteBehavior.Cascade);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Configure(EntityTypeBuilder<Room> builder)

builder.HasMany(p => p.Sessions)
.WithOne(p => p.Room)
.OnDelete(DeleteBehavior.Restrict);
.OnDelete(DeleteBehavior.Cascade);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ public void Configure(EntityTypeBuilder<Session> builder)

builder.HasOne(p => p.Movie)
.WithMany(p => p.Sessions)
.HasForeignKey(p => p.MovieId);
.HasForeignKey(p => p.MovieId)
.OnDelete(DeleteBehavior.Cascade);

builder.HasOne(p => p.Room)
.WithMany(p => p.Sessions)
.HasForeignKey(p => p.RoomId);
.HasForeignKey(p => p.RoomId)
.OnDelete(DeleteBehavior.Cascade);
}
}
}
83 changes: 46 additions & 37 deletions src/api/Theater.WebApi/ClientApp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions src/api/Theater.WebApi/ClientApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
},
"private": true,
"dependencies": {
"@angular/animations": "10.0.9",
"@angular/animations": "10.0.14",
"@angular/cdk": "^10.1.3",
"@angular/common": "10.0.9",
"@angular/compiler": "10.0.9",
"@angular/core": "10.0.9",
"@angular/forms": "10.0.9",
"@angular/common": "10.0.14",
"@angular/compiler": "10.0.14",
"@angular/core": "10.0.14",
"@angular/forms": "10.0.14",
"@angular/material": "^10.1.3",
"@angular/platform-browser": "10.0.9",
"@angular/platform-browser-dynamic": "10.0.9",
"@angular/platform-browser": "10.0.14",
"@angular/platform-browser-dynamic": "10.0.14",
"@angular/platform-server": "^10.0.14",
"@angular/router": "10.0.9",
"@angular/router": "10.0.14",
"@nguniversal/express-engine": "^10.0.2",
"@nguniversal/module-map-ngfactory-loader": "8.2.6",
"aspnet-prerendering": "^3.0.1",
Expand All @@ -37,7 +37,7 @@
"oidc-client": "^1.10.1",
"popper.js": "^1.16.1",
"rxjs": "^6.6.2",
"zone.js": "0.10.3"
"zone.js": "0.11.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1000.8",
Expand All @@ -48,17 +48,17 @@
"@types/express": "^4.17.7",
"@types/jasmine": "^3.5.14",
"@types/jasminewd2": "~2.0.8",
"@types/node": "~14.0.27",
"@types/node": "~14.6.2",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.2",
"karma": "^5.1.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~3.3.1",
"karma-jasmine": "~4.0.1",
"karma-jasmine-html-reporter": "^1.5.4",
"parse5": "^6.0.1",
"typescript": "3.9.7"
"typescript": "^3.9.6"
},
"optionalDependencies": {
"node-sass": "^4.14.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,7 @@ export class RoomsListComponent implements OnInit {
if (error.match('RoomWithSession')) {
this.snackBar.open(`Room included in a session`);
}

this.isLoading = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,7 @@ export class SessionsListComponent implements OnInit {
if (error.match('SessionLessThanTenDaysToStart')) {
this.snackBar.open(`Can't delete session with less than 10 days to start`);
}

this.isLoading = false;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const environment = {
production: true,
apiUrl: 'http://localhost:5001/',
apiUrl: 'http://localhost:5000/',
};
4 changes: 4 additions & 0 deletions src/api/Theater.WebApi/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Production": {
"commandName": "IISExpress",
"launchBrowser": true
}
}
}
2 changes: 2 additions & 0 deletions src/api/Theater.WebApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
spa.ApplicationBuilder.UseCors("TheaterCorsPolicy");
});
}
}
Expand Down

0 comments on commit 2ec831c

Please sign in to comment.