Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 41fecdb

Browse files
Initial additions
1 parent 41e0ba6 commit 41fecdb

File tree

19 files changed

+546
-0
lines changed

19 files changed

+546
-0
lines changed

‎.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "src/client"]
2+
path = src/client
3+
url = https://github.com/mariadb-developers/todo-app-client

‎README.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# TODO
2+
3+
**TODO** is a web application that introduces you to the power, performance, and simplicity of [MariaDB](https://mariadb.com/products/).
4+
5+
<p align="center" spacing="10">
6+
<kbd>
7+
<img src="media/demo.gif" />
8+
</kbd>
9+
</p>
10+
11+
This application is made of two parts:
12+
13+
* Client
14+
- web UI that communicates with REST endpoints available through an API app (see below).
15+
- is a React.js project located in the [client](src/client) folder.
16+
* API
17+
- uses [MySqlConnector](https://github.com/mysql-net/MySqlConnector) in combination with the [Pomelo.EntityFramework.Core v.6.0.0.0](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql) and [Entity Framework 6](https://docs.microsoft.com/en-us/ef/) to connect to MariaDB.
18+
- is a .NET solution located int the [api](src/api) folder.
19+
20+
This README will walk you through the steps for getting the TODO web application up and running using MariaDB.
21+
22+
# Table of Contents
23+
1. [Requirements](#requirements)
24+
2. [Getting started with MariaDB](#mariadb)
25+
3. [Get the code](#code)
26+
4. [Create the database and table](#schema)
27+
5. [Configure, build and run the apps](#app)
28+
1. [Configure](#configure-api-app)
29+
4. [Build and run the .NET API app](#build-run-api)
30+
5. [Build and run the Client app](#build-run-client)
31+
6. [Support and contribution](#support-contribution)
32+
7. [License](#license)
33+
34+
## Requirements <a name="requirements"></a>
35+
36+
This sample application requires the following to be installed/enabled on your machine:
37+
38+
* [.NET 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
39+
* [Visual Studio](https://visualstudio.microsoft.com/vs/)
40+
* [Node.js (v. 12+)](https://nodejs.org/docs/latest-v12.x/api/index.html) (for the Client/UI app)
41+
* [NPM (v. 6+)](https://docs.npmjs.com/) (for the Client/UI app)
42+
* [MariaDB command-line client](https://mariadb.com/products/skysql/docs/clients/mariadb-clients/mariadb-client/) (optional), used to connect to MariaDB database instances.
43+
44+
## 1.) Getting Started with MariaDB <a name="mariadb"></a>
45+
46+
[MariaDB](https://mariadb.com) is a community-developed, commercially supported relational database management system, and the database you'll be using for this application.
47+
48+
If you don't have a MariaDB database up and running you can find more information on how to download, install and start using a MariaDB database in the [MariaDB Quickstart Guide](https://github.com/mariadb-developers/mariadb-getting-started).
49+
50+
## 2.) Get the code <a name="code"></a>
51+
52+
First, use [git](git-scm.org) (through CLI or a client) to retrieve the code using `git clone`:
53+
54+
```
55+
$ git clone https://github.com/mariadb-developers/todo-app-python.git
56+
```
57+
58+
Next, because this repo uses a [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules), you will need to pull the [client application](https://github.com/mariadb-developers/todo-app-client) using:
59+
60+
```bash
61+
$ git submodule update --init --recursive
62+
```
63+
64+
## 3.) Create the database and table <a name="schema"></a>
65+
66+
[Connect to your MariaDB database](https://mariadb.com/products/skysql/docs/clients/) (from [Step #2](#mariadb)) and execute the following SQL scripts using the following options:
67+
68+
a.) Use the [MariaDB command-line client](https://mariadb.com/products/skysql/docs/clients/mariadb-clients/mariadb-client/) to execute the SQL contained within [schema.sql](schema.sql).
69+
70+
_Example command:_
71+
```bash
72+
$ mariadb --host HOST_ADDRESS --port PORT_NO --user USER --password PASSWORD < schema.sql
73+
```
74+
75+
**OR**
76+
77+
b.) Copy, paste and execute the raw SQL commands contained in [schema.sql](schema.sql) using a [client of your choice](https://mariadb.com/products/skysql/docs/clients/).
78+
79+
```sql
80+
CREATE DATABASE todo;
81+
82+
CREATE TABLE todo.tasks (
83+
id INT(11) unsigned NOT NULL AUTO_INCREMENT,
84+
description VARCHAR(500) NOT NULL,
85+
completed BOOLEAN NOT NULL DEFAULT 0,
86+
PRIMARY KEY (id)
87+
);
88+
```
89+
90+
## 4.) Configure, Build and Run the App <a name="app"></a>
91+
92+
This application is made of two parts:
93+
94+
* Client
95+
- web UI that communicates with REST endpoints available through an API app (see below).
96+
- is a React.js project located in the [client](src/client) folder.
97+
* API
98+
- uses [MySqlConnector](https://github.com/mysql-net/MySqlConnector) in combination with the [Pomelo.EntityFramework.Core v.6.0.0.0](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql) and [Entity Framework 6](https://docs.microsoft.com/en-us/ef/) to connect to MariaDB.
99+
- is a .NET solution located int the [api](src/api) folder.
100+
101+
The following steps, `a` through `c`, will walk you through the process of configuring, building and running the `api` and `client` applications.
102+
103+
### a.) Configure the app <a name="configure-api-app"></a>
104+
105+
Configure the MariaDB connection with **your** connection details in [appsettings.json](src/api/Todo.API/appsettings.json) file.
106+
107+
Example implementation:
108+
109+
```json
110+
{
111+
"Logging": {
112+
"LogLevel": {
113+
"Default": "Information",
114+
"Microsoft": "Warning",
115+
"Microsoft.Hosting.Lifetime": "Information"
116+
}
117+
},
118+
"ConnectionStrings": {
119+
"TodoDatabase": "host=localhost;port=3306;user id=app_user;password=Password123!;database=todo;"
120+
},
121+
"AllowedHosts": "*"
122+
}
123+
```
124+
125+
### b.) Build and run the [API app](src/api) <a name="build-run-api"></a>
126+
127+
Build and run the application using Visual Studio. The solution will be built and the Web API project will begin listening on http://localhost:8080.
128+
129+
### c.) Build and run the [UI (Client) app](src/client) <a name="build-run-client"></a>
130+
131+
Once the API project is running you can now communicate with the exposed endpoints directly (via HTTP requests) or with the application UI, which is contained with the [client](src/client) folder of this repo.
132+
133+
To start the [client](src/client) application follow the instructions [here](https://github.com/mariadb-developers/todo-app-client).
134+
135+
## Support and Contribution <a name="support-contribution"></a>
136+
137+
Please feel free to submit PR's, issues or requests to this project project directly.
138+
139+
If you have any other questions, comments, or looking for more information on MariaDB please check out:
140+
141+
* [MariaDB Developer Hub](https://mariadb.com/developers)
142+
* [MariaDB Community Slack](https://r.mariadb.com/join-community-slack)
143+
144+
Or reach out to us diretly via:
145+
146+
* [developers@mariadb.com](mailto:developers@mariadb.com)
147+
* [MariaDB Twitter](https://twitter.com/mariadb)
148+
149+
## License <a name="license"></a>
150+
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=plastic)](https://opensource.org/licenses/MIT)

‎media/demo.gif

233 KB
Loading[フレーム]

‎schema.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE DATABASE todo;
2+
3+
CREATE TABLE todo.tasks (
4+
id INT(11) unsigned NOT NULL AUTO_INCREMENT,
5+
description VARCHAR(500) NOT NULL,
6+
completed BOOLEAN NOT NULL DEFAULT 0,
7+
PRIMARY KEY (id)
8+
);

‎src/api/.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
*.swp
2+
*.*~
3+
project.lock.json
4+
.DS_Store
5+
*.pyc
6+
nupkg/
7+
8+
# Visual Studio Code
9+
.vscode
10+
11+
# Rider
12+
.idea
13+
14+
# User-specific files
15+
*.suo
16+
*.user
17+
*.userosscache
18+
*.sln.docstates
19+
20+
# Build results
21+
[Dd]ebug/
22+
[Dd]ebugPublic/
23+
[Rr]elease/
24+
[Rr]eleases/
25+
x64/
26+
x86/
27+
build/
28+
bld/
29+
[Bb]in/
30+
[Oo]bj/
31+
[Oo]ut/
32+
msbuild.log
33+
msbuild.err
34+
msbuild.wrn
35+
36+
# Visual Studio 2015
37+
.vs/

‎src/api/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# TODO - .NET 6 (C#) Web API project using Entity Framework 6 & MySQLConnector
2+
3+
This .NET solution uses [MySqlConnector](https://github.com/mysql-net/MySqlConnector) in combination with the [Pomelo.EntityFramework.Core v.6.0.0.0](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql) and [Entity Framework 6](https://docs.microsoft.com/en-us/ef/) Object Mapping library to connect to and communicate to a MariaDB database instance.
4+
5+
1. [Requirements](#requirements)
6+
2. [Getting started with the app](#getting-started)
7+
1. [Configure the code](#configure-code)
8+
3. [Build and run the app](#run-app)
9+
10+
## Requirements <a name="requirements"></a>
11+
12+
This sample was created using the following techologies and they must be installed before proceeding.
13+
14+
* [Visual Studio](https://visualstudio.microsoft.com/vs/)
15+
16+
## Getting started with the app <a name="getting-started"></a>
17+
18+
First, open [Todo.sln](Todo.sln) in Visual Studio.
19+
20+
### Configure the code <a name="configure-code"></a>
21+
22+
Configure the MariaDB connection with **your** connection details in [appsettings.json](Todo.API/appsettings.json) file.
23+
24+
Example implementation:
25+
26+
```json
27+
{
28+
"Logging": {
29+
"LogLevel": {
30+
"Default": "Information",
31+
"Microsoft": "Warning",
32+
"Microsoft.Hosting.Lifetime": "Information"
33+
}
34+
},
35+
"ConnectionStrings": {
36+
"TodoDatabase": "host=localhost;port=3306;user id=root;password=Password123!;database=todo;"
37+
},
38+
"AllowedHosts": "*"
39+
}
40+
```
41+
42+
### Run the app <a name="run-app"></a>
43+
44+
Once you've pulled down the code and have verified built the project you're ready to run the application!
45+
46+
1. Build and run the application using Visual Studio. The solution will be built and the Web API project will begin listening on http://localhost:8080.
47+
48+
2. Within the terminal, navigate to the [client](../../../client) folder and execute the following CLI command to start the React.js application.
49+
50+
```bash
51+
$ npm install
52+
$ npm start
53+
```
54+
55+
3. Open a browser window and navigate to http://localhost:3000 (which will load the TODO application web UI).
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Todo.Core.Services;
3+
4+
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
5+
6+
namespace Todo.API.Controllers
7+
{
8+
[Route("api/[controller]")]
9+
public class TasksController : Controller
10+
{
11+
private readonly ITaskService _taskService;
12+
13+
public TasksController(ITaskService taskService)
14+
{
15+
_taskService = taskService;
16+
}
17+
18+
// GET: api/tasks
19+
[HttpGet]
20+
public async Task<IActionResult> Get()
21+
{
22+
var result = await _taskService.FindAllAsync();
23+
return Ok(result);
24+
}
25+
26+
// POST api/tasks
27+
[HttpPost]
28+
public async Task<IActionResult> Post([FromBody] Core.Models.Task task)
29+
{
30+
var result = await _taskService.InsertAsync(task);
31+
return Ok(result);
32+
}
33+
34+
// PUT api/tasks
35+
[HttpPut]
36+
public async Task<IActionResult> Put([FromBody] Core.Models.Task task)
37+
{
38+
var result = await _taskService.UpdateAsync(task);
39+
return Ok(result);
40+
}
41+
42+
// DELETE api/tasks?id=5
43+
[HttpDelete]
44+
public async Task<IActionResult> Delete([FromQuery] int id)
45+
{
46+
var result = await _taskService.DeleteAsync(id);
47+
return Ok(result);
48+
}
49+
}
50+
}

‎src/api/Todo.API/Program.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using Todo.Core.Data;
3+
using Todo.Core.Services;
4+
5+
var builder = WebApplication.CreateBuilder(args);
6+
7+
// Add services to the container.
8+
builder.Services.AddDbContextPool<MariaDbContext>(options => options
9+
.UseMySql(builder.Configuration.GetConnectionString("TodoDatabase"), new MariaDbServerVersion(new Version(10, 6, 5)))
10+
);
11+
builder.Services.AddScoped<ITaskService, TaskService>();
12+
builder.Services.AddControllers();
13+
14+
var app = builder.Build();
15+
16+
// Configure the HTTP request pipeline.
17+
18+
app.UseAuthorization();
19+
20+
app.MapControllers();
21+
22+
app.Run();
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:6442",
8+
"sslPort": 0
9+
}
10+
},
11+
"profiles": {
12+
"Todo.API": {
13+
"commandName": "Project",
14+
"dotnetRunMessages": true,
15+
"launchBrowser": true,
16+
"launchUrl": "api/tasks",
17+
"applicationUrl": "http://localhost:8080",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
},
22+
"IIS Express": {
23+
"commandName": "IISExpress",
24+
"launchBrowser": true,
25+
"launchUrl": "api/tasks",
26+
"environmentVariables": {
27+
"ASPNETCORE_ENVIRONMENT": "Development"
28+
}
29+
}
30+
}
31+
}

‎src/api/Todo.API/Todo.API.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\Todo.Core\Todo.Core.csproj" />
11+
</ItemGroup>
12+
13+
</Project>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /