forked from MDCPS/DamageAssessment_Backend
Merged new dev changes
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DamageAssesment.Api.Surveys.Db
|
||||
{
|
||||
@ -6,23 +7,20 @@ namespace DamageAssesment.Api.Surveys.Db
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
[Required]
|
||||
public string Title { get; set; }
|
||||
|
||||
//[StringLength(1000)]
|
||||
//public string Description { get; set; }
|
||||
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
public DateTime? StartDate { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
|
||||
public DateTime? EndDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
|
||||
//public DateTime CreatedDate { get; set; }
|
||||
|
||||
//[StringLength(6)]
|
||||
//public string EmployeeID { get; set; }
|
||||
public DateTime CreatedDate { get; set; } = DateTime.Now;
|
||||
/*
|
||||
[StringLength(10)]
|
||||
[ForeignKey("Employee")]
|
||||
public string EmployeeId { get; set; }
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace DamageAssesment.Api.Surveys.Db
|
||||
{
|
||||
public class SurveyTranslation
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
[ForeignKey("Survey")]
|
||||
public int SurveyId { get; set; }
|
||||
|
||||
[StringLength(200)]
|
||||
[Required]
|
||||
public string Title { get; set; }
|
||||
public string Language { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2,19 +2,32 @@
|
||||
|
||||
namespace DamageAssesment.Api.Surveys.Db
|
||||
{
|
||||
public class SurveysDbContext:DbContext
|
||||
public class SurveysDbContext : DbContext
|
||||
{
|
||||
private IConfiguration _Configuration { get; set; }
|
||||
public SurveysDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
|
||||
{
|
||||
_Configuration = configuration;
|
||||
}
|
||||
|
||||
public DbSet<Db.Survey> Surveys { get; set; }
|
||||
public DbSet<Db.SurveyTranslation> SurveysTranslation { get; set; }
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||
{
|
||||
// connect to sql server with connection string from app settings
|
||||
options.UseSqlServer(_Configuration.GetConnectionString("SurveyConnection"));
|
||||
}
|
||||
public DbSet<Db.Survey> Surveys { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<Survey>()
|
||||
.Property(item => item.Id)
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
modelBuilder.Entity<SurveyTranslation>()
|
||||
.Property(item => item.Id)
|
||||
.ValueGeneratedOnAdd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user