Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/web-api.web/Data/ToDoContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore;
using web_api.web.Models;

namespace web_api.web.Data
{
public class ToDoContext : DbContext
{
public ToDoContext(DbContextOptions<ToDoContext> options) : base(options)
{
}

public DbSet<ToDo> ToDos { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

// Configure ToDo entity
modelBuilder.Entity<ToDo>(entity =>
{
entity.HasKey(e => e.Id);
entity.Property(e => e.Id).ValueGeneratedOnAdd();
entity.Property(e => e.Title).HasMaxLength(200);
entity.Property(e => e.Description).HasMaxLength(1000);
entity.Property(e => e.IsCompleted).IsRequired();
});
}
}
}

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

36 changes: 36 additions & 0 deletions src/web-api.web/Migrations/20250604210641_InitialCreate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace web_api.web.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ToDos",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
IsCompleted = table.Column<bool>(type: "bit", nullable: false),
Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ToDos", x => x.Id);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ToDos");
}
}
}
50 changes: 50 additions & 0 deletions src/web-api.web/Migrations/ToDoContextModelSnapshot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using web_api.web.Data;

#nullable disable

namespace web_api.web.Migrations
{
[DbContext(typeof(ToDoContext))]
partial class ToDoContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

modelBuilder.Entity("web_api.web.Models.ToDo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");

b.Property<bool>("IsCompleted")
.HasColumnType("bit");

b.Property<string>("Title")
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");

b.HasKey("Id");

b.ToTable("ToDos");
});
#pragma warning restore 612, 618
}
}
}
22 changes: 22 additions & 0 deletions src/web-api.web/Models/CoinbaseExchangeRateResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Text.Json.Serialization;

namespace web_api.web.Models;

/// <summary>
/// Represents the response from Coinbase API v2/exchange-rates endpoint
/// </summary>
public record CoinbaseExchangeRateResponse(
[property: JsonPropertyName("data")]
ExchangeRateData Data
);

/// <summary>
/// Contains the exchange rate data including base currency and rates
/// </summary>
public record ExchangeRateData(
[property: JsonPropertyName("currency")]
string Currency,

[property: JsonPropertyName("rates")]
Dictionary<string, string> Rates
);
Loading