Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Forecast DB model #575

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions backend/Core/Consultants/Consultant.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema;
using Core.Engagements;
using Core.Forecasts;
using Core.Organizations;
using Core.PlannedAbsences;
using Core.Staffings;
Expand Down Expand Up @@ -34,6 +35,8 @@ public class Consultant

public List<Staffing> Staffings { get; set; } = new();

public List<Forecast> Forecasts { get; set; } = new();


public int YearsOfExperience
{
Expand Down
17 changes: 17 additions & 0 deletions backend/Core/Forecasts/Forecast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations.Schema;
using Core.Consultants;

namespace Core.Forecasts;

public class Forecast
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }

public required int ConsultantId { get; set; }
public required Consultant Consultant { get; set; }
astride marked this conversation as resolved.
Show resolved Hide resolved

public required DateOnly MonthYear { get; set; }

public int? AdjustedValue { get; set; }
}
6 changes: 6 additions & 0 deletions backend/Infrastructure/DatabaseContext/ApplicationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Core.Consultants;
using Core.Customers;
using Core.Engagements;
using Core.Forecasts;
using Core.Organizations;
using Core.PlannedAbsences;
using Core.Staffings;
Expand All @@ -27,6 +28,7 @@ public class ApplicationContext(DbContextOptions options) : DbContext(options)
public DbSet<Engagement> Project { get; init; } = null!;
public DbSet<Staffing> Staffing { get; init; } = null!;
public DbSet<Agreement> Agreements { get; init; } = null!;
public DbSet<Forecast> Forecasts { get; init; } = null!;


protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
Expand Down Expand Up @@ -118,6 +120,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasMany(consultant => consultant.PlannedAbsences)
.WithOne(absence => absence.Consultant);

modelBuilder.Entity<Consultant>()
.HasMany(c => c.Forecasts)
.WithOne(f => f.Consultant);

modelBuilder.Entity<Consultant>()
.Property(v => v.Degree)
.HasConversion<string>();
Expand Down
Loading
Loading