This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TodoApi.Models | |
{ | |
public class TodoItem | |
{ | |
public long Id { get; set; } | |
public string Name { get; set; } | |
public bool IsComplete { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet add package Microsoft.EntityFrameworkCore.Sqlite | |
dotnet add package Microsoft.EntityFrameworkCore.Design | |
dotnet restore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.EntityFrameworkCore; | |
namespace TodoApi.Models | |
{ | |
public class TodoContext : DbContext | |
{ | |
public TodoContext(DbContextOptions<TodoContext> options) | |
: base(options) | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.EntityFrameworkCore; | |
using Microsoft.Extensions.DependencyInjection; | |
using TodoApi.Models; | |
namespace TodoApi | |
{ | |
public class Startup | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.EntityFrameworkCore; | |
using Microsoft.Extensions.DependencyInjection; | |
using TodoApi.Models; | |
namespace TodoApi | |
{ | |
public class Startup | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet ef migrations add InitialCreate | |
dotnet ef database update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Mvc; | |
using System.Collections.Generic; | |
using System.Linq; | |
using TodoApi.Models; | |
namespace TodoApi.Controllers | |
{ | |
[Route("api/[controller]")] | |
[ApiController] | |
public class TodoController : ControllerBase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet] | |
public ActionResult<List<TodoItem>> GetAll() | |
{ | |
return _context.TodoItems.ToList(); | |
} | |
[HttpGet("{id}", Name = "GetTodo")] | |
public ActionResult<TodoItem> GetById(long id) | |
{ | |
var item = _context.TodoItems.Find(id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install –g @angular/cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ng new TodoListApp | |
mkdir TodoListApp | |
ng serve --open |
OlderNewer