Added Azure sql setup for User access micro service

This commit is contained in:
uppuv
2023-09-29 12:30:20 -04:00
110 changed files with 2525 additions and 639 deletions

View File

@ -0,0 +1,31 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Responses.Db
{
public class SurveyResponse
{
[Key]
public int Id { get; set; }
[ForeignKey("Survey")]
public int SurveyId { get; set; }
[ForeignKey("Location")]
public int LocationId { get; set; }
[StringLength(6)]
[ForeignKey("Employee")]
public int EmployeeId { get; set; }
public DateTime? CreatedDate { get; set; } = DateTime.Now;
[StringLength(50)]
public string? ClientDevice { get; set; }
[StringLength(250)]
public string? KeyAnswerResult { get; set; }
public double? Longitute { get; set; }
public double? Latitude { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore;
namespace DamageAssesment.Api.Responses.Db
{
public class SurveyResponseDbContext:DbContext
{
private IConfiguration _Configuration { get; set; }
public SurveyResponseDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
{
_Configuration = configuration;
}
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
// connect to sql server with connection string from app settings
options.UseSqlServer(_Configuration.GetConnectionString("SurveyResponseConnection"));
}
public DbSet<Db.SurveyResponse> SurveyResponses { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<SurveyResponse>()
.Property(item => item.Id)
.ValueGeneratedOnAdd();
}
}
}