@ -24,6 +24,12 @@ You can find source code of the completed application [here](https://github.com/
{{end}}
{{if UI=="NG"}}
* [Node v14.x](https://nodejs.org/)
{{end}}
## Creating a New Solution
We will use the [ABP CLI](../../CLI.md) to create new solutions with the ABP Framework. You can run the following command in a command-line terminal to install it:
Then create an empty folder, open a command-line terminal and execute the following command in the terminal:
````bash
abp new TodoApp{{if UI=="Blazor"}} -u blazor{{else if UI=="BlazorServer"}} -u blazor-server{{end}}{{if DB=="Mongo"}} -d mongodb{{end}}
abp new TodoApp{{if UI=="Blazor"}} -u blazor{{else if UI=="BlazorServer"}} -u blazor-server{{else if UI=="NG"}} -u angular{{end}}{{if DB=="Mongo"}} -d mongodb{{end}}
````
{{if UI=="NG"}}
This will create a new solution, named *TodoApp* with `angular` and `aspnet-core` folders. Once the solution is ready, open the ASP.NET Core solution in your favorite IDE.
{{else}}
This will create a new solution, named *TodoApp*. Once the solution is ready, open it in your favorite IDE.
{{end}}
### Create the Database
If you are using Visual Studio, right click to the `TodoApp.DbMigrator` project, select *Set as StartUp Project*, then hit *Ctrl+F5* to run it without debugging. It will create the initial database and seed the initial data.
@ -69,6 +83,33 @@ Ensure the `TodoApp.HttpApi.Host` project is the startup project, then run the a
You can explore and test your HTTP API with this UI. Now, we can set the `TodoApp.Blazor` as the startup project and run it to open the actual Blazor application UI:
{{else if UI=="NG"}}
It is good to run the application before starting the development. The solution has two main applications;
* `TodoApp.HttpApi.Host` (in the .NET solution) host the server-side HTTP API.
* `angular` folder contains the Angular application.
Ensure the `TodoApp.HttpApi.Host` project is the startup project, then run the application (Ctrl+F5 in Visual Studio) to see the server-side HTTP API on the [Swagger UI](https://swagger.io/tools/swagger-ui/):
You can explore and test your HTTP API with this UI. If that works, we can run the Angular client application.
First, run the following command to restore the NPM packages;
````bash
npm install
````
It will take some time to install all the packages. Then you can run the application using the following command:
````bash
npm start
````
This command takes time, but eventually runs and opens the application in your default browser:
{{end}}

@ -146,7 +187,7 @@ You can apply changes to the database using the following command, in the same c
dotnet ef database update
````
> If you are using Visual Studio, you may want to use `Add-Migration Added_TodoItem` and `Update-Database` commands in the *Package Manager Console (PMC)*. In this case, ensure that {{if UI=="MVC"}}`TodoApp.Web`{{else if UI=="Blazor"}}`TodoApp.HttpApi.Host`{{end}} is the startup project and `TodoApp.EntityFrameworkCore.DbMigrations` is the *Default Project* in PMC.
> If you are using Visual Studio, you may want to use `Add-Migration Added_TodoItem` and `Update-Database` commands in the *Package Manager Console (PMC)*. In this case, ensure that {{if UI=="MVC"}}`TodoApp.Web`{{else if UI=="BlazorServer"}}`TodoApp.Blazor`{{else if UI=="Blazor" || UI=="NG"}}`TodoApp.HttpApi.Host`{{end}} is the startup project and `TodoApp.EntityFrameworkCore.DbMigrations` is the *Default Project* in PMC.
{{else if DB=="Mongo"}}
@ -242,7 +283,7 @@ namespace TodoApp
_todoItemRepository = todoItemRepository;
}
// TODO: Implement the methods
// TODO: Implement the methods here...
}
}
````
@ -620,7 +661,149 @@ If you run the `TodoApp.HttpApi.Host` application, you can see the Todo API:
{{end # Blazor}}
{{end # Blazor || BlazorServer}}
{{else if UI=="NG"}}
### Service Proxy Generation
ABP provides a handy feature to automatically create client-side services to easily consume HTTP APIs provided by the server.
Ensure that the `TodoApp.HttpApi.Host` project is running, open a command-line terminal in the `angular` folder and type the following command:
````
abp generate-proxy
````
If everything goes well, it should generate an output like shown below:
this.toasterService.info('Deleted the todo item.');
});
}
}
````
We've used the `todoService` to get the list of todo items and assigned the returning value to the `todoItems` array. We've also added `create` and `delete` methods. These methods will be used in the view side.
### home.component.html
Open the `/angular/src/app/home/home.component.html` file and replace its content with the following code block: