Skip to content
Snippets Groups Projects
Commit dd52bd77 authored by Enzo Santangelo Dodera's avatar Enzo Santangelo Dodera
Browse files

Merge branch 'feature/bedelia-login' into 'develop'

Feature/bedelia login

See merge request !47
parents 194e373f 20d10b1b
No related branches found
No related tags found
1 merge request!47Feature/bedelia login
Pipeline #10665 passed
Showing
with 1274 additions and 2 deletions
...@@ -135,5 +135,23 @@ namespace Bedelia.Controllers ...@@ -135,5 +135,23 @@ namespace Bedelia.Controllers
return Ok(result); return Ok(result);
} }
[HttpPost("login")]
public async Task<IActionResult> Login(UserLoginDto userLoginDto)
{
var user = await _context.Users.FirstOrDefaultAsync(x => x.IdentityCard == userLoginDto.IdentityCard);
if (user == null)
{
return BadRequest(string.Format("el usuario con cédula {0} no existe en bedelia", userLoginDto.IdentityCard));
}
if (user.Password != userLoginDto.Password)
{
return BadRequest(string.Format("Contraseña incorrecta"));
}
return Ok();
}
} }
} }
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace Bedelia.Dtos
{
public class UserLoginDto
{
[Required]
public string IdentityCard { get; set; }
[Required]
public string Password { get; set; }
}
}
...@@ -11,6 +11,7 @@ using Tsi1.Api.Models; ...@@ -11,6 +11,7 @@ using Tsi1.Api.Models;
using Tsi1.BusinessLayer.Dtos; using Tsi1.BusinessLayer.Dtos;
using Tsi1.BusinessLayer.Helpers; using Tsi1.BusinessLayer.Helpers;
using Tsi1.BusinessLayer.Interfaces; using Tsi1.BusinessLayer.Interfaces;
using Tsi1.DataLayer.Entities;
namespace Tsi1.Api.Controllers namespace Tsi1.Api.Controllers
{ {
...@@ -24,19 +25,22 @@ namespace Tsi1.Api.Controllers ...@@ -24,19 +25,22 @@ namespace Tsi1.Api.Controllers
private readonly IUserTypeService _userTypeService; private readonly IUserTypeService _userTypeService;
private readonly ITenantService _tenantService; private readonly ITenantService _tenantService;
private readonly IEmailService _emailService; private readonly IEmailService _emailService;
private readonly IBedeliaService _bedeliaService;
public UserController( public UserController(
IJwtAuthManager jwtAuthManager, IJwtAuthManager jwtAuthManager,
IUserService userService, IUserService userService,
IUserTypeService userTypeService, IUserTypeService userTypeService,
ITenantService tenantService, ITenantService tenantService,
IEmailService emailService) IEmailService emailService,
IBedeliaService bedeliaService)
{ {
_jwtAuthManager = jwtAuthManager; _jwtAuthManager = jwtAuthManager;
_userService = userService; _userService = userService;
_userTypeService = userTypeService; _userTypeService = userTypeService;
_tenantService = tenantService; _tenantService = tenantService;
_emailService = emailService; _emailService = emailService;
_bedeliaService = bedeliaService;
} }
[AllowAnonymous] [AllowAnonymous]
...@@ -59,7 +63,24 @@ namespace Tsi1.Api.Controllers ...@@ -59,7 +63,24 @@ namespace Tsi1.Api.Controllers
return BadRequest(tenant.Message); return BadRequest(tenant.Message);
} }
var result = await _userService.Authenticate(userName, request.Password, tenant.Data.Id); var result = new ServiceResult<User>();
if (tenant.Data.IsLoginBedelia)
{
var bedeliaResult = await _bedeliaService.Login(userName, request.Password);
if (bedeliaResult.HasError)
{
return BadRequest(bedeliaResult.Message);
}
result = await _userService.GetByIdentityCard(userName);
}
else
{
result = await _userService.Authenticate(userName, request.Password, tenant.Data.Id);
}
if (result.HasError) if (result.HasError)
{ {
return BadRequest(result.Message); return BadRequest(result.Message);
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Tsi1.BusinessLayer.Dtos
{
public class BedeliaLoginDto
{
public string IdentityCard { get; set; }
public string Password { get; set; }
}
}
...@@ -8,5 +8,6 @@ namespace Tsi1.BusinessLayer.Dtos ...@@ -8,5 +8,6 @@ namespace Tsi1.BusinessLayer.Dtos
{ {
public string Name { get; set; } public string Name { get; set; }
public string Theme { get; set; } public string Theme { get; set; }
public bool IsLoginBedelia { get; set; }
} }
} }
...@@ -9,5 +9,7 @@ namespace Tsi1.BusinessLayer.Dtos ...@@ -9,5 +9,7 @@ namespace Tsi1.BusinessLayer.Dtos
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Theme { get; set; } public string Theme { get; set; }
public bool IsLoginBedelia { get; set; }
} }
} }
...@@ -9,5 +9,6 @@ namespace Tsi1.BusinessLayer.Dtos ...@@ -9,5 +9,6 @@ namespace Tsi1.BusinessLayer.Dtos
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Theme { get; set; } public string Theme { get; set; }
public bool IsLoginBedelia { get; set; }
} }
} }
...@@ -12,5 +12,7 @@ namespace Tsi1.BusinessLayer.Interfaces ...@@ -12,5 +12,7 @@ namespace Tsi1.BusinessLayer.Interfaces
Task<ServiceResult<bool>> IsValidUser(string identityCard); Task<ServiceResult<bool>> IsValidUser(string identityCard);
Task<ServiceResult<bool>> CloseRecord(string courseName, List<UserGradeDto> userGrades); Task<ServiceResult<bool>> CloseRecord(string courseName, List<UserGradeDto> userGrades);
Task<ServiceResult<bool>> Login(string identityCard, string password);
} }
} }
...@@ -18,6 +18,8 @@ namespace Tsi1.BusinessLayer.Interfaces ...@@ -18,6 +18,8 @@ namespace Tsi1.BusinessLayer.Interfaces
Task<ServiceResult<UserDetailDto>> GetById(int userId); Task<ServiceResult<UserDetailDto>> GetById(int userId);
Task<ServiceResult<User>> GetByIdentityCard(string IdentityCard);
Task<ServiceResult<User>> GetByUsername(string username, int tenantId); Task<ServiceResult<User>> GetByUsername(string username, int tenantId);
Task<ServiceResult<bool>> UpdatePassword(int userId, string password); Task<ServiceResult<bool>> UpdatePassword(int userId, string password);
......
...@@ -57,5 +57,29 @@ namespace Tsi1.BusinessLayer.Services ...@@ -57,5 +57,29 @@ namespace Tsi1.BusinessLayer.Services
return result; return result;
} }
public async Task<ServiceResult<bool>> Login(string identityCard, string password)
{
var result = new ServiceResult<bool>();
var loginDto = new BedeliaLoginDto()
{
IdentityCard = identityCard,
Password = password
};
var jsonInString = JsonConvert.SerializeObject(loginDto);
var model = new StringContent(jsonInString, Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync($"api/Users/login", model);
if (response.StatusCode != HttpStatusCode.OK)
{
result.HasError = true;
var errorMessage = await response.Content.ReadAsStringAsync();
result.AddMessage(errorMessage);
}
return result;
}
} }
} }
...@@ -382,5 +382,27 @@ namespace Tsi1.BusinessLayer.Services ...@@ -382,5 +382,27 @@ namespace Tsi1.BusinessLayer.Services
return result; return result;
} }
public async Task<ServiceResult<User>> GetByIdentityCard(string IdentityCard)
{
var result = new ServiceResult<User>();
var user = await _context.Users
.AsNoTracking()
.Include(x => x.Student)
.Include(x => x.UserType)
.FirstOrDefaultAsync(x => x.Student.IdentityCard == IdentityCard);
if (user == null)
{
result.HasError = true;
result.Message = string.Format(ErrorMessages.UserDoesNotExist, IdentityCard);
return result;
}
result.Data = user;
return result;
}
} }
} }
...@@ -19,6 +19,7 @@ namespace Tsi1.DataLayer.Entities ...@@ -19,6 +19,7 @@ namespace Tsi1.DataLayer.Entities
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Theme { get; set; } public string Theme { get; set; }
public bool IsLoginBedelia { get; set; }
public ICollection<Course> Courses { get; set; } public ICollection<Course> Courses { get; set; }
public ICollection<Professor> Professors { get; set; } public ICollection<Professor> Professors { get; set; }
......
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Tsi1.DataLayer;
namespace Tsi1.DataLayer.Migrations
{
[DbContext(typeof(Tsi1Context))]
[Migration("20201212192149_add-column-IsLoginBedelia-to-tenant")]
partial class addcolumnIsLoginBedeliatotenant
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
.HasAnnotation("ProductVersion", "3.1.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("Tsi1.DataLayer.Entities.Activity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("CourseId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp without time zone");
b.Property<int?>("EvaluationId")
.HasColumnType("integer");
b.Property<bool>("IsVideoConference")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("CourseId");
b.HasIndex("EvaluationId")
.IsUnique();
b.ToTable("Activities");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.AnswerOption", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Name");
b.ToTable("AnswerOptions");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Attendance", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("ActivityId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp without time zone");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ActivityId");
b.HasIndex("UserId");
b.ToTable("Attendances");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Communication", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int?>("CourseId")
.HasColumnType("integer");
b.Property<bool>("IsGlobal")
.HasColumnType("boolean");
b.Property<int?>("TenantId")
.HasColumnType("integer");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("character varying(1000)");
b.Property<DateTime>("ValidUntil")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.HasIndex("CourseId");
b.HasIndex("TenantId");
b.HasIndex("ValidUntil");
b.ToTable("Communications");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Connection", b =>
{
b.Property<string>("ConnectionId")
.HasColumnType("text");
b.Property<string>("GroupName")
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("ConnectionId");
b.HasIndex("GroupName");
b.ToTable("Connections");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Course", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<bool>("HasPassword")
.HasColumnType("boolean");
b.Property<bool>("IsTemplate")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("character varying(50)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("character varying(200)");
b.Property<int>("TenantId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("TenantId");
b.HasIndex("Name", "TenantId")
.IsUnique();
b.ToTable("Courses");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Evaluation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("EvaluationTypeId")
.HasColumnType("integer");
b.Property<bool>("IsCompleted")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("EvaluationTypeId");
b.ToTable("Evaluations");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.EvaluationInscription", b =>
{
b.Property<int>("EvaluationId")
.HasColumnType("integer");
b.Property<int>("StudentId")
.HasColumnType("integer");
b.Property<decimal>("Grade")
.HasColumnType("decimal(5,2)");
b.Property<bool>("HasAttended")
.HasColumnType("boolean");
b.HasKey("EvaluationId", "StudentId");
b.HasIndex("StudentId");
b.ToTable("EvaluationInscriptions");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.EvaluationType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("EvaluationTypes");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.File", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<bool>("IsSubmission")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("character varying(50)");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("character varying(1000)");
b.Property<int?>("SubmissionId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("Path")
.IsUnique();
b.HasIndex("SubmissionId")
.IsUnique();
b.ToTable("Files");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Forum", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<bool>("IsAutomaticSubscription")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.ToTable("Forums");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.ForumUser", b =>
{
b.Property<int>("ForumId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("ForumId", "UserId");
b.HasIndex("UserId");
b.ToTable("ForumUsers");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Group", b =>
{
b.Property<string>("Name")
.HasColumnType("text");
b.HasKey("Name");
b.ToTable("Groups");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Post", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<DateTime>("Date")
.HasColumnType("timestamp without time zone");
b.Property<int>("ForumId")
.HasColumnType("integer");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("character varying(100)");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("ForumId", "Title")
.IsUnique();
b.ToTable("Posts");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.PostMessage", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Content")
.IsRequired()
.HasColumnType("character varying(10485760)");
b.Property<DateTime>("Date")
.HasColumnType("timestamp without time zone");
b.Property<int>("PostId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PostId");
b.HasIndex("UserId");
b.ToTable("PostMessages");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Professor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("IdentityCard")
.IsRequired()
.HasColumnType("character varying(50)");
b.Property<int>("TenantId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("TenantId");
b.HasIndex("IdentityCard", "TenantId")
.IsUnique();
b.ToTable("Professors");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.ProfessorCourse", b =>
{
b.Property<int>("ProfessorId")
.HasColumnType("integer");
b.Property<int>("CourseId")
.HasColumnType("integer");
b.HasKey("ProfessorId", "CourseId");
b.HasIndex("CourseId");
b.ToTable("ProfessorCourses");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Section", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("CourseId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("character varying(255)");
b.Property<int>("Order")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CourseId");
b.ToTable("Sections");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.SectionItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int?>("FileId")
.HasColumnType("integer");
b.Property<int?>("ForumId")
.HasColumnType("integer");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<int>("SectionId")
.HasColumnType("integer");
b.Property<int>("SectionItemTypeId")
.HasColumnType("integer");
b.Property<int?>("SurveyId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("FileId")
.IsUnique();
b.HasIndex("ForumId")
.IsUnique();
b.HasIndex("SectionId");
b.HasIndex("SectionItemTypeId");
b.HasIndex("SurveyId")
.IsUnique();
b.ToTable("SectionItems");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.SectionItemType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.ToTable("SectionItemTypes");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Student", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("IdentityCard")
.IsRequired()
.HasColumnType("character varying(50)");
b.Property<int>("TenantId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("TenantId");
b.HasIndex("IdentityCard", "TenantId")
.IsUnique();
b.ToTable("Students");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.StudentCourse", b =>
{
b.Property<int>("StudentId")
.HasColumnType("integer");
b.Property<int>("CourseId")
.HasColumnType("integer");
b.HasKey("StudentId", "CourseId");
b.HasIndex("CourseId");
b.ToTable("StudentCourses");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.StudentCourseResult", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("CourseId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp without time zone");
b.Property<int>("Result")
.HasColumnType("integer");
b.Property<int>("StudentId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CourseId");
b.HasIndex("StudentId");
b.ToTable("StudentCourseResults");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Submission", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int?>("EvaluationId")
.HasColumnType("integer");
b.Property<int>("FileId")
.HasColumnType("integer");
b.Property<decimal>("Grade")
.HasColumnType("decimal(5,2)");
b.Property<bool>("IsCompleted")
.HasColumnType("boolean");
b.Property<int>("StudentId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("EvaluationId");
b.HasIndex("StudentId", "FileId")
.IsUnique();
b.ToTable("Submissions");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Survey", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<bool>("IsGlobal")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("character varying(255)");
b.Property<int?>("TenantId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("Name");
b.HasIndex("TenantId");
b.ToTable("Surveys");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.SurveyAnswer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("AnswerOptionId")
.HasColumnType("integer");
b.Property<int>("SurveyQuestionId")
.HasColumnType("integer");
b.Property<int>("SurveyResponseId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("AnswerOptionId");
b.HasIndex("SurveyQuestionId");
b.HasIndex("SurveyResponseId");
b.ToTable("SurveyAnswers");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.SurveyQuestion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Question")
.IsRequired()
.HasColumnType("character varying(255)");
b.Property<int>("SurveyId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SurveyId");
b.ToTable("SurveyQuestions");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.SurveyResponse", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("SurveyId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SurveyId");
b.HasIndex("UserId");
b.ToTable("SurveyResponses");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Tenant", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<bool>("IsLoginBedelia")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("character varying(50)");
b.Property<string>("Theme")
.IsRequired()
.HasColumnType("character varying(200)");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Tenants");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<DateTime>("Birthdate")
.HasColumnType("timestamp without time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("character varying(255)");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("character varying(255)");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("character varying(255)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("character varying(255)");
b.Property<int?>("ProfessorId")
.HasColumnType("integer");
b.Property<int?>("StudentId")
.HasColumnType("integer");
b.Property<int>("TenantId")
.HasColumnType("integer");
b.Property<int>("UserTypeId")
.HasColumnType("integer");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("ProfessorId")
.IsUnique();
b.HasIndex("StudentId")
.IsUnique();
b.HasIndex("TenantId");
b.HasIndex("UserTypeId");
b.HasIndex("Username", "TenantId")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.UserType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("UserTypes");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Activity", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Course", "Course")
.WithMany("Activities")
.HasForeignKey("CourseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.Evaluation", "Evaluation")
.WithOne("Activity")
.HasForeignKey("Tsi1.DataLayer.Entities.Activity", "EvaluationId");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Attendance", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Activity", "Activity")
.WithMany("Attendances")
.HasForeignKey("ActivityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.User", "User")
.WithMany("Attendances")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Communication", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Course", "Course")
.WithMany("Communications")
.HasForeignKey("CourseId");
b.HasOne("Tsi1.DataLayer.Entities.Tenant", "Tenant")
.WithMany("Communications")
.HasForeignKey("TenantId");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Connection", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Group", "Group")
.WithMany("Connections")
.HasForeignKey("GroupName");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Course", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Tenant", "Tenant")
.WithMany("Courses")
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Evaluation", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.EvaluationType", "EvaluationType")
.WithMany()
.HasForeignKey("EvaluationTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.EvaluationInscription", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Evaluation", "Evaluation")
.WithMany("EvaluationInscriptions")
.HasForeignKey("EvaluationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.Student", "Student")
.WithMany("EvaluationInscriptions")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.File", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Submission", "Submission")
.WithOne("File")
.HasForeignKey("Tsi1.DataLayer.Entities.File", "SubmissionId");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.ForumUser", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Forum", "Forum")
.WithMany("ForumUsers")
.HasForeignKey("ForumId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.User", "User")
.WithMany("ForumUsers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Post", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Forum", "Forum")
.WithMany("Posts")
.HasForeignKey("ForumId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.User", "User")
.WithMany("Posts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.PostMessage", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Post", "Post")
.WithMany("PostMessages")
.HasForeignKey("PostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.User", "User")
.WithMany("PostMessages")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Professor", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Tenant", "Tenant")
.WithMany("Professors")
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.ProfessorCourse", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Course", "Course")
.WithMany("ProfessorCourses")
.HasForeignKey("CourseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.Professor", "Professor")
.WithMany("ProfessorCourses")
.HasForeignKey("ProfessorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Section", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Course", "Course")
.WithMany("Sections")
.HasForeignKey("CourseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.SectionItem", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.File", "File")
.WithOne("SectionItem")
.HasForeignKey("Tsi1.DataLayer.Entities.SectionItem", "FileId");
b.HasOne("Tsi1.DataLayer.Entities.Forum", "Forum")
.WithOne("SectionItem")
.HasForeignKey("Tsi1.DataLayer.Entities.SectionItem", "ForumId");
b.HasOne("Tsi1.DataLayer.Entities.Section", "Section")
.WithMany("SectionItems")
.HasForeignKey("SectionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.SectionItemType", "SectionItemType")
.WithMany("SectionItems")
.HasForeignKey("SectionItemTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.Survey", "Survey")
.WithOne("SectionItem")
.HasForeignKey("Tsi1.DataLayer.Entities.SectionItem", "SurveyId");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Student", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Tenant", "Tenant")
.WithMany("Students")
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.StudentCourse", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Course", "Course")
.WithMany("StudentCourses")
.HasForeignKey("CourseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.Student", "Student")
.WithMany("StudentCourses")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.StudentCourseResult", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Course", "Course")
.WithMany("StudentCourseResults")
.HasForeignKey("CourseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.Student", "Student")
.WithMany("StudentCourseResults")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Submission", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Evaluation", null)
.WithMany("Submissions")
.HasForeignKey("EvaluationId");
b.HasOne("Tsi1.DataLayer.Entities.Student", "Student")
.WithMany("Submissions")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.Survey", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Tenant", "Tenant")
.WithMany("Surveys")
.HasForeignKey("TenantId");
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.SurveyAnswer", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.AnswerOption", "AnswerOption")
.WithMany("SurveyAnswers")
.HasForeignKey("AnswerOptionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.SurveyQuestion", "SurveyQuestion")
.WithMany("SurveyAnswers")
.HasForeignKey("SurveyQuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.SurveyResponse", "SurveyResponse")
.WithMany("SurveyAnswers")
.HasForeignKey("SurveyResponseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.SurveyQuestion", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Survey", "Survey")
.WithMany("SurveyQuestions")
.HasForeignKey("SurveyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.SurveyResponse", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Survey", "Survey")
.WithMany("SurveyResponses")
.HasForeignKey("SurveyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.User", "User")
.WithMany("SurveyResponses")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Tsi1.DataLayer.Entities.User", b =>
{
b.HasOne("Tsi1.DataLayer.Entities.Professor", "Professor")
.WithOne("User")
.HasForeignKey("Tsi1.DataLayer.Entities.User", "ProfessorId");
b.HasOne("Tsi1.DataLayer.Entities.Student", "Student")
.WithOne("User")
.HasForeignKey("Tsi1.DataLayer.Entities.User", "StudentId");
b.HasOne("Tsi1.DataLayer.Entities.Tenant", "Tenant")
.WithMany("Users")
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Tsi1.DataLayer.Entities.UserType", "UserType")
.WithMany()
.HasForeignKey("UserTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace Tsi1.DataLayer.Migrations
{
public partial class addcolumnIsLoginBedeliatotenant : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsLoginBedelia",
table: "Tenants",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsLoginBedelia",
table: "Tenants");
}
}
}
...@@ -700,6 +700,9 @@ namespace Tsi1.DataLayer.Migrations ...@@ -700,6 +700,9 @@ namespace Tsi1.DataLayer.Migrations
.HasColumnType("integer") .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<bool>("IsLoginBedelia")
.HasColumnType("boolean");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("character varying(50)"); .HasColumnType("character varying(50)");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment