First example of Venue endpoint
This commit is contained in:
parent
ff4fcbf19b
commit
7fa1811586
6
backend/LeedsBeerQuest.API/.gitignore
vendored
6
backend/LeedsBeerQuest.API/.gitignore
vendored
@ -603,3 +603,9 @@ fabric.properties
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/aspnetcore,csharp,rider
|
||||
|
||||
*.csv#
|
||||
*.db
|
||||
*.db-shm
|
||||
*.db-wal
|
||||
*.swp
|
||||
|
@ -0,0 +1,26 @@
|
||||
using LeedsBeerQuest.API.Data.Contexts;
|
||||
using LeedsBeerQuest.API.Data.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LeedsBeerQuest.API.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class VenueController
|
||||
{
|
||||
private readonly LeedsBeerQuestDbContext _lbqContext;
|
||||
|
||||
public VenueController(LeedsBeerQuestDbContext lbqContext)
|
||||
{
|
||||
_lbqContext = lbqContext;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IEnumerable<Venue>> Get()
|
||||
{
|
||||
return await _lbqContext.Venues
|
||||
.Include(v => v.Category)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
@ -1,6 +1,20 @@
|
||||
namespace LeedsBeerQuest.API.Data.Contexts;
|
||||
using LeedsBeerQuest.API.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
public class LeedsBeerQuestDbContext
|
||||
namespace LeedsBeerQuest.API.Data.Contexts;
|
||||
|
||||
public class LeedsBeerQuestDbContext : DbContext
|
||||
{
|
||||
public LeedsBeerQuestDbContext()
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<Venue> Venues { get; set; }
|
||||
|
||||
// Don't need to define these, but explicitly adding them makes them a little more discoverable.
|
||||
public DbSet<Category> Categories { get; set; }
|
||||
public DbSet<Tag> Tags { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||
=> options.UseSqlite("Data Source=lbq.db");
|
||||
}
|
144
backend/LeedsBeerQuest.API/LeedsBeerQuest.API/Data/Migrations/20221029013630_InitialCreate.Designer.cs
generated
Normal file
144
backend/LeedsBeerQuest.API/LeedsBeerQuest.API/Data/Migrations/20221029013630_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,144 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using LeedsBeerQuest.API.Data.Contexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LeedsBeerQuest.API.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(LeedsBeerQuestDbContext))]
|
||||
[Migration("20221029013630_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "6.0.10");
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Category", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Name")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Categories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Tag", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("VenueId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("VenueId");
|
||||
|
||||
b.ToTable("Tags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Venue", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("DateAttended")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Excerpt")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("Latitude")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("Longitude")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsAmenities")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsAtmosphere")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsBeer")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsValue")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Thumbnail")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Twitter")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("Venues");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Tag", b =>
|
||||
{
|
||||
b.HasOne("LeedsBeerQuest.API.Data.Models.Venue", null)
|
||||
.WithMany("Tags")
|
||||
.HasForeignKey("VenueId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Venue", b =>
|
||||
{
|
||||
b.HasOne("LeedsBeerQuest.API.Data.Models.Category", "Category")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Venue", b =>
|
||||
{
|
||||
b.Navigation("Tags");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LeedsBeerQuest.API.Data.Migrations
|
||||
{
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Categories",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Categories", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Venues",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
CategoryId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Url = table.Column<string>(type: "TEXT", nullable: false),
|
||||
DateAttended = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
Excerpt = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Thumbnail = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Latitude = table.Column<decimal>(type: "TEXT", nullable: false),
|
||||
Longitude = table.Column<decimal>(type: "TEXT", nullable: false),
|
||||
Address = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Phone = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Twitter = table.Column<string>(type: "TEXT", nullable: true),
|
||||
StarsBeer = table.Column<decimal>(type: "TEXT", nullable: false),
|
||||
StarsAtmosphere = table.Column<decimal>(type: "TEXT", nullable: false),
|
||||
StarsAmenities = table.Column<decimal>(type: "TEXT", nullable: false),
|
||||
StarsValue = table.Column<decimal>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Venues", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Venues_Categories_CategoryId",
|
||||
column: x => x.CategoryId,
|
||||
principalTable: "Categories",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Tags",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
VenueId = table.Column<int>(type: "INTEGER", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Tags", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Tags_Venues_VenueId",
|
||||
column: x => x.VenueId,
|
||||
principalTable: "Venues",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Tags_VenueId",
|
||||
table: "Tags",
|
||||
column: "VenueId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Venues_CategoryId",
|
||||
table: "Venues",
|
||||
column: "CategoryId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Tags");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Venues");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Categories");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using LeedsBeerQuest.API.Data.Contexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LeedsBeerQuest.API.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(LeedsBeerQuestDbContext))]
|
||||
[Migration("20221029020048_Categories_Name_String")]
|
||||
partial class Categories_Name_String
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "6.0.10");
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Category", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Categories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Tag", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("VenueId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("VenueId");
|
||||
|
||||
b.ToTable("Tags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Venue", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("DateAttended")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Excerpt")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("Latitude")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("Longitude")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsAmenities")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsAtmosphere")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsBeer")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsValue")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Thumbnail")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Twitter")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("Venues");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Tag", b =>
|
||||
{
|
||||
b.HasOne("LeedsBeerQuest.API.Data.Models.Venue", null)
|
||||
.WithMany("Tags")
|
||||
.HasForeignKey("VenueId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Venue", b =>
|
||||
{
|
||||
b.HasOne("LeedsBeerQuest.API.Data.Models.Category", "Category")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Venue", b =>
|
||||
{
|
||||
b.Navigation("Tags");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LeedsBeerQuest.API.Data.Migrations
|
||||
{
|
||||
public partial class Categories_Name_String : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Name",
|
||||
table: "Categories",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Name",
|
||||
table: "Categories",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using LeedsBeerQuest.API.Data.Contexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LeedsBeerQuest.API.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(LeedsBeerQuestDbContext))]
|
||||
partial class LeedsBeerQuestDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "6.0.10");
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Category", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Categories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Tag", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("VenueId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("VenueId");
|
||||
|
||||
b.ToTable("Tags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Venue", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("DateAttended")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Excerpt")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("Latitude")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("Longitude")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsAmenities")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsAtmosphere")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsBeer")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StarsValue")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Thumbnail")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Twitter")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("Venues");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Tag", b =>
|
||||
{
|
||||
b.HasOne("LeedsBeerQuest.API.Data.Models.Venue", null)
|
||||
.WithMany("Tags")
|
||||
.HasForeignKey("VenueId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Venue", b =>
|
||||
{
|
||||
b.HasOne("LeedsBeerQuest.API.Data.Models.Category", "Category")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("LeedsBeerQuest.API.Data.Models.Venue", b =>
|
||||
{
|
||||
b.Navigation("Tags");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LeedsBeerQuest.API.Data.Models;
|
||||
|
||||
public class Category
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LeedsBeerQuest.API.Data.Models;
|
||||
|
||||
public class Tag
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LeedsBeerQuest.API.Data.Models;
|
||||
|
||||
public class Venue
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int CategoryId { get; set; }
|
||||
public Category Category { get; set; }
|
||||
public string Url { get; set; }
|
||||
public DateTime DateAttended { get; set; }
|
||||
public string Excerpt { get; set; }
|
||||
public string Thumbnail { get; set; }
|
||||
public decimal Latitude { get; set; }
|
||||
public decimal Longitude { get; set; }
|
||||
public string Address { get; set; }
|
||||
public string? Phone { get; set; }
|
||||
public string? Twitter { get; set; }
|
||||
public decimal StarsBeer { get; set; }
|
||||
public decimal StarsAtmosphere { get; set; }
|
||||
public decimal StarsAmenities { get; set; }
|
||||
public decimal StarsValue { get; set; }
|
||||
public ICollection<Tag> Tags { get; set; }
|
||||
}
|
@ -7,11 +7,18 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EntityFramework" Version="6.4.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.10" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Data\Models" />
|
||||
<Folder Include="Data\Migrations" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,3 +1,5 @@
|
||||
using LeedsBeerQuest.API.Data.Contexts;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
@ -7,6 +9,9 @@ builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
// App services
|
||||
builder.Services.AddScoped<LeedsBeerQuestDbContext>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
Loading…
Reference in New Issue
Block a user