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
81 changes: 0 additions & 81 deletions Controllers/BooksController.cs

This file was deleted.

12 changes: 12 additions & 0 deletions Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;

namespace EduCoreSuite.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
}
}
158 changes: 0 additions & 158 deletions Controllers/InstitutionsController.cs

This file was deleted.

31 changes: 19 additions & 12 deletions Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,31 @@ namespace EduCoreSuite.Data
{
public class ApplicationDbContext : DbContext
{
public DbSet<Book> Books { get; set; }
public DbSet<Institution> Institutions { get; set; }
public DbSet<County> Counties { get; set; }
public DbSet<Subcounty> SubCounties { get; set; }


public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}

public DbSet<Institution> Institutions { get; set; }
public DbSet<County> Counties { get; set; }
public DbSet<SubCounty> SubCounties { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Add model configurations here if needed
modelBuilder.Entity<Subcounty>()
.HasOne(sc => sc.County)
.WithMany(c => c.SubCounties)
.HasForeignKey(sc => sc.CountyID);
base.OnModelCreating(modelBuilder);

// Seed Counties
modelBuilder.Entity<County>().HasData(
new County { CountyID = 1, CountyName = "Nairobi" },
new County { CountyID = 2, CountyName = "Mombasa" }
);

// Seed SubCounties
modelBuilder.Entity<SubCounty>().HasData(
new SubCounty { SubCountyID = 1, SubCountyName = "Westlands", CountyID = 1 },
new SubCounty { SubCountyID = 2, SubCountyName = "Lang'ata", CountyID = 1 },
new SubCounty { SubCountyID = 3, SubCountyName = "Likoni", CountyID = 2 }
);
}
}
}
}
43 changes: 22 additions & 21 deletions EduCoreSuite.csproj
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<Folder Include="Services\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Services\" />
<Folder Include="Views\Home\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.7" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.7" />
</ItemGroup>

</Project>
12 changes: 6 additions & 6 deletions Models/County.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace EduCoreSuite.Models
{
public class County
{
[Key]
[Required]
public int CountyID { get; set; }
public string CountyName { get; set; }

public ICollection<Subcounty> SubCounties { get; set; }

[Required]
[StringLength(100)]
public string CountyName { get; set; }

public List<SubCounty> SubCounties { get; set; }
}
}
Loading