Create Project
- Blazor Server App
- [Auth]-[Individual User Account]-[Save in User Account App]
Active Database
- Startup.cs
Create a new Database
- RankingDB
- Create in Local DB
- Click [Property]
- Copy context in [Link String]
- Paste in
appsetting.json
Register User
- Register User in Web
- Execute the solution
- Click [Register]
- Fill forms and Click [Register] button
- If you register first user, then click [Migrations Apply] button then the button will be change to [Migrations Applied]
- Press [F5] on Keyborad or refresh button in web
- Click [Click here to comfirm your account], then your email will be comfirmed
- Login with this account
- You can see your log in data in topbar
Check User
- Check User in Database
- Open
dbo.AspNetUsers
Data - You can check your registed account
- Open
Migration
- Models
- Create
Data\Models
folder
- Create
- Data\Models\GameResult.cs
- Data\ApplicationDbContext.cs
- Input Data in Database directly
Database Version Management
- Up()
- Builds operations that will migrate the database
up
- That is, builds the operations that will take the database from the state left in by the previous migration so that it is up-to-date with regard to migartion
- This method must to be overridden in each class the inherits from
Migration
- Builds operations that will migrate the database
- Down()
- Builds operations that will migrate the database
down
- That is, builds the operations that will take the database from the state left in by the this migration so that it returns to the state that it was in before this migration was applied.
- This method must to be overridden in each class the inherits from
Migration
if bothup
anddown
migrations are to be supported. If it is not overridden, then calling it will throw and it will not to be possible to migrate in thedown
direction.
- Builds operations that will migrate the database
Authorization
- AuthorizeView
- Displays differing content depending on the user’s authorization status
- Authorized
- The content that will be displayed if the user is authorized.
- NotAuthorized
- The content that will be displayed if the user is not authorized.
CRUD
- FormResult Method
- Creates a System.Threading.Tasks.Task`1 that’s completed successfully with the specified result.
CREATE
- SaveChanges Method
- Saves all changes made in this context to the database.
- This method will automatically call Microsoft.EntityFrameworkCore.ChangeTracking.ChangeTracker.DetectChanges to discover any changes to entity instances before saving to the underlying database.
- This can be disabled via Microsoft.EntityFrameworkCore.ChangeTracking.ChangeTracker.AutoDetectChangesEnabled.
READ
UPDATE
DELETE
SharedData
Add a new project
- SharedData
- Class Library(.Net Core)
- Data\GameResult.cs
PostMan
Download
- Postman
- Download Postman
- deactivate [Settings]-[Enable SSL certificate verification]
WebApi
Add a new project
- WebApi
- ASP.NET Core Web Application
- template: API
- package: Microsoft.EntityFrameworkCore, Microsoft.EntityFrameworkCore.Design, Microsoft.EntityFrameworkCore.SqlServer
Reference
- Dependency
- references
SharedData
- references
Database Connect
- Data\ApplicationDbContext.cs
- Startup.cs
- appsettings.json
Controllers\RankingController.cs
- REST (Representational State Transfer)
- Reusing features from the original HTTP communication to create a data transmission rule
- ApiController feature
- can return C# object
- if return null, then 204 Response(No Content) in cli
- string → text/plain
- rest(int, bool) → application/json
- Read
- ex: GET/ api/ ranking → get all items
- ex: GET/ api/ ranking/1 → get item which is id=1
- Add data in
dbo.GameResults
- Create
- ex: POST/ api/ ranking → Create item(real data in Body)
- Update
- ex: PUT /api/ ranking(not used in web because of PUT authority problem) → request update item(real data in Body)
- Delete
- DELETE/ api/ ranking/ 1(not used in web because of DELETE authority problem) → delete item which is id=1
Interlock RankingApp and WebApi
RankingApp
- Reference
- reference
SharedData
- reference
- Folder Cleanup
- delete
Data\Models
- delete
- Data\ApplicationDbContext.cs
- Data\Services\RankingService.cs
- Razor.razor
- Startup.cs
- use number in
Properties\launchSetting.json
- use number in
Build
Start several project at once
- Solution
- [Property] - [Several start project]
Result(CRUD)
CREATE
READ
UPDATE
DELETE
Interlock RankingApp, WebApi and Unity
WebTest
- WebManager.cs
- Put your WebApi Server Port number in
_baseUrl
- Put your WebApi Server Port number in
- GameObject