Skip to content
Snippets Groups Projects

data-load

5 files
+ 1721
34
Compare changes
  • Side-by-side
  • Inline

Files

@@ -64,21 +64,34 @@ namespace Tsi1.BusinessLayer.DataLoad
@@ -64,21 +64,34 @@ namespace Tsi1.BusinessLayer.DataLoad
public async Task LoadDataAsync()
public async Task LoadDataAsync()
{
{
// TENANTS
// TENANTS
var tenants = new List<Tenant>
var newTenants = new List<Tenant>
{
{
new Tenant
new Tenant
{
{
Name = TenantAdmin.Name,
Name = TenantAdmin.Name,
 
Theme = "pulse"
},
},
new Tenant
new Tenant
{
{
Name = "fing",
Name = "fing",
 
Theme = "darkly"
},
},
 
new Tenant
 
{
 
Name = "fmed",
 
Theme = "sketchy"
 
 
}
};
};
_context.Tenants.AddRange(tenants);
_context.Tenants.AddRange(newTenants);
await _context.SaveChangesAsync();
await _context.SaveChangesAsync();
 
var tenants = await _context.Tenants.ToListAsync();
 
var tenantFing = tenants.FirstOrDefault(x => x.Name == "fing");
 
var tenantFmed = tenants.FirstOrDefault(x => x.Name == "fmed");
 
var tenantAdminId = tenants.FirstOrDefault(x => x.Name == TenantAdmin.Name).Id;
 
// USER TYPES
// USER TYPES
var udelarAdminUserType = new UserType
var udelarAdminUserType = new UserType
{
{
@@ -111,33 +124,54 @@ namespace Tsi1.BusinessLayer.DataLoad
@@ -111,33 +124,54 @@ namespace Tsi1.BusinessLayer.DataLoad
{
{
new User
new User
{
{
 
Id = -1,
UserTypeId = udelarAdminUserType.Id,
UserTypeId = udelarAdminUserType.Id,
Username = "admin",
Username = "admin",
Password = "admin",
Password = "admin",
FirstName = "admin",
FirstName = "admin",
LastName = "admin",
LastName = "admin",
Email = "admin@mail.com",
Email = "admin@mail.com",
TenantId = 1,
TenantId = tenantAdminId,
},
},
 
// FING
new User
new User
{
{
 
Id = -2,
UserTypeId = studentUserType.Id,
UserTypeId = studentUserType.Id,
Username = "enzo",
Username = "enzo",
Password = "enzo",
Password = "enzo",
FirstName = "Enzo",
FirstName = "Enzo",
LastName = "Santangelo",
LastName = "Santangelo",
Email = "enzo@mail.com",
Email = "enzo020895@gmail.com",
 
Student = new Student
 
{
 
TenantId = tenantFing.Id,
 
IdentityCard = "4932876-0",
 
},
 
TenantId = tenantFing.Id,
 
},
 
 
new User
 
{
 
Id = -3,
 
UserTypeId = studentUserType.Id,
 
Username = "lucca",
 
Password = "lucca",
 
FirstName = "Lucca",
 
LastName = "Santangelo",
 
Email = "luccasant95@gmail.com",
Student = new Student
Student = new Student
{
{
TenantId = 2,
TenantId = tenantFing.Id,
IdentityCard = "13242344-5",
IdentityCard = "4932877-6",
},
},
TenantId = 2,
TenantId = tenantFing.Id,
},
},
new User
new User
{
{
 
Id = -4,
UserTypeId = studentUserType.Id,
UserTypeId = studentUserType.Id,
Username = "mathias",
Username = "mathias",
Password = "mathias",
Password = "mathias",
@@ -146,37 +180,142 @@ namespace Tsi1.BusinessLayer.DataLoad
@@ -146,37 +180,142 @@ namespace Tsi1.BusinessLayer.DataLoad
Email = "mathias@mail.com",
Email = "mathias@mail.com",
Student = new Student
Student = new Student
{
{
IdentityCard = "3782346-5",
IdentityCard = "1234567-8",
TenantId = 2,
TenantId = tenantFing.Id,
},
},
TenantId = 2,
TenantId = tenantFing.Id,
},
},
new User
new User
{
{
 
Id = -5,
UserTypeId = professorUserType.Id,
UserTypeId = professorUserType.Id,
Username = "prof1",
Username = "jperez",
Password = "prof1",
Password = "jperez",
FirstName = "Juan",
FirstName = "Juan",
LastName = "Perez",
LastName = "Perez",
Email = "jp@mail.com",
Email = "jperez@mail.com",
Professor = new Professor
Professor = new Professor
{
{
TenantId = 2,
Id = -1,
 
TenantId = tenantFing.Id,
IdentityCard = "98754342-5",
IdentityCard = "98754342-5",
},
},
TenantId = 2,
TenantId = tenantFing.Id,
 
},
 
 
new User
 
{
 
Id = -6,
 
UserTypeId = professorUserType.Id,
 
Username = "csuarez",
 
Password = "csuarez",
 
FirstName = "Carlos",
 
LastName = "Suarez",
 
Email = "csuarez@mail.com",
 
Professor = new Professor
 
{
 
Id = -2,
 
TenantId = tenantFing.Id,
 
IdentityCard = "2133453-5",
 
},
 
TenantId = tenantFing.Id,
},
},
new User
new User
{
{
 
Id = -7,
UserTypeId = facultyAdminUserType.Id,
UserTypeId = facultyAdminUserType.Id,
Username = "fing",
Username = "lrodriguez",
Password = "fing",
Password = "lrodriguez",
FirstName = "fing",
FirstName = "Luis",
LastName = "fing",
LastName = "Rodriguez",
Email = "fing@mail.com",
Email = "lrodriguez@mail.com",
TenantId = 2,
TenantId = tenantFing.Id,
 
},
 
 
//FMED
 
 
new User
 
{
 
Id = -8,
 
UserTypeId = studentUserType.Id,
 
Username = "marcelo",
 
Password = "rodriguez",
 
FirstName = "Marcelo",
 
LastName = "Rodriguez",
 
Email = "marcelo@gmail.com",
 
Student = new Student
 
{
 
TenantId = tenantFmed.Id,
 
IdentityCard = "76347887-0",
 
},
 
TenantId = tenantFmed.Id,
 
},
 
 
new User
 
{
 
Id = -9,
 
UserTypeId = studentUserType.Id,
 
Username = "rodrigo",
 
Password = "sastre",
 
FirstName = "Rodrigo",
 
LastName = "Sastre",
 
Email = "rsastre@gmail.com",
 
Student = new Student
 
{
 
TenantId = tenantFmed.Id,
 
IdentityCard = "73642873-6",
 
},
 
TenantId = tenantFmed.Id,
 
},
 
 
new User
 
{
 
Id = -10,
 
UserTypeId = professorUserType.Id,
 
Username = "dgonzalez",
 
Password = "dgonzalez",
 
FirstName = "Diego",
 
LastName = "Gonzalez",
 
Email = "dgonzalez@mail.com",
 
Professor = new Professor
 
{
 
Id = -3,
 
TenantId = tenantFmed.Id,
 
IdentityCard = "897349827-5",
 
},
 
TenantId = tenantFmed.Id,
 
},
 
 
new User
 
{
 
Id = -11,
 
UserTypeId = professorUserType.Id,
 
Username = "gfernandez",
 
Password = "gfernandez",
 
FirstName = "Guillermo",
 
LastName = "Fernandez",
 
Email = "gfernandez@mail.com",
 
Professor = new Professor
 
{
 
Id = -4,
 
TenantId = tenantFmed.Id,
 
IdentityCard = "782698091-5",
 
},
 
TenantId = tenantFmed.Id,
 
},
 
 
new User
 
{
 
Id = -12,
 
UserTypeId = facultyAdminUserType.Id,
 
Username = "jsilva",
 
Password = "jsilva",
 
FirstName = "Jorge",
 
LastName = "Silva",
 
Email = "jsilva@mail.com",
 
TenantId = tenantFmed.Id,
},
},
};
};
@@ -213,40 +352,144 @@ namespace Tsi1.BusinessLayer.DataLoad
@@ -213,40 +352,144 @@ namespace Tsi1.BusinessLayer.DataLoad
await _context.SaveChangesAsync();
await _context.SaveChangesAsync();
 
 
// EVALUATION TYPES
 
var examEvaluationType = new EvaluationType
 
{
 
Name = "Exam"
 
};
 
_context.EvaluationTypes.Add(examEvaluationType);
 
 
var laboratoryEvaluationType = new EvaluationType
 
{
 
Name = "Laboratory"
 
};
 
_context.EvaluationTypes.Add(laboratoryEvaluationType);
 
 
var midTermEvaluationType = new EvaluationType
 
{
 
Name = "MidTerm"
 
};
 
_context.EvaluationTypes.Add(midTermEvaluationType);
 
 
await _context.SaveChangesAsync();
 
 
// COURSES
// COURSES
var courses = new List<Course>
var courses = new List<Course>
{
{
new Course
new Course
{
{
Id = 1,
Id = -1,
Name = "Calculo 1",
Name = "Calculo 1",
TenantId = 2
TenantId = tenantFing.Id,
 
IsPublic = true,
 
HasPassword = true,
 
Password = "fing",
 
},
},
new Course
new Course
{
{
Id = 2,
Id = -2,
Name = "GAL 1",
Name = "GAL 1",
TenantId = 2
TenantId = tenantFing.Id,
 
IsPublic = true,
},
},
new Course
new Course
{
{
Id = 3,
Id = -3,
Name = "Fisica 1",
Name = "Fisica 1",
TenantId = 2
TenantId = tenantFing.Id,
}
IsPublic = false,
 
},
 
 
new Course
 
{
 
Id = -11,
 
Name = "Neurociencias",
 
TenantId = tenantFmed.Id,
 
IsPublic = true,
 
},
 
 
new Course
 
{
 
Id = -21,
 
Name = "Cardiovascular y Respiratorio",
 
TenantId = tenantFmed.Id,
 
IsPublic = false,
 
HasPassword = true,
 
Password = "fmed"
 
},
 
};
};
_context.Courses.AddRange(courses);
_context.Courses.AddRange(courses);
await _context.SaveChangesAsync();
await _context.SaveChangesAsync();
 
// PROFESSOR COURSES
 
 
var professorCourses = new List<ProfessorCourse>
 
{
 
new ProfessorCourse
 
{
 
CourseId = -1,
 
ProfessorId = -1,
 
},
 
 
new ProfessorCourse
 
{
 
CourseId = -2,
 
ProfessorId = -1,
 
},
 
 
new ProfessorCourse
 
{
 
CourseId = -3,
 
ProfessorId = -1,
 
},
 
 
new ProfessorCourse
 
{
 
CourseId = -1,
 
ProfessorId = -2,
 
},
 
 
new ProfessorCourse
 
{
 
CourseId = -2,
 
ProfessorId = -2,
 
},
 
 
new ProfessorCourse
 
{
 
CourseId = -11,
 
ProfessorId = -3,
 
},
 
 
new ProfessorCourse
 
{
 
CourseId = -21,
 
ProfessorId = -3,
 
},
 
 
new ProfessorCourse
 
{
 
CourseId = -11,
 
ProfessorId = -4,
 
},
 
};
 
 
_context.ProfessorCourses.AddRange(professorCourses);
 
 
await _context.SaveChangesAsync();
// SECTIONS
// SECTIONS
var section1 = new Section
var section1 = new Section
{
{
CourseId = 1,
CourseId = -1,
Name = "General",
Name = "General",
Order = 1,
Order = 1,
SectionItems = new List<SectionItem>
SectionItems = new List<SectionItem>
@@ -269,13 +512,13 @@ namespace Tsi1.BusinessLayer.DataLoad
@@ -269,13 +512,13 @@ namespace Tsi1.BusinessLayer.DataLoad
Name = "General"
Name = "General"
}
}
},
},
}
}
};
};
_context.Sections.Add(section1);
_context.Sections.Add(section1);
var section2 = new Section
var section2 = new Section
{
{
CourseId = 2,
CourseId = -2,
Name = "General",
Name = "General",
Order = 1,
Order = 1,
SectionItems = new List<SectionItem>
SectionItems = new List<SectionItem>
@@ -296,7 +539,7 @@ namespace Tsi1.BusinessLayer.DataLoad
@@ -296,7 +539,7 @@ namespace Tsi1.BusinessLayer.DataLoad
var section3 = new Section
var section3 = new Section
{
{
CourseId = 1,
CourseId = -1,
Name = "Tema 1",
Name = "Tema 1",
Order = 2,
Order = 2,
SectionItems = new List<SectionItem>
SectionItems = new List<SectionItem>
@@ -314,6 +557,94 @@ namespace Tsi1.BusinessLayer.DataLoad
@@ -314,6 +557,94 @@ namespace Tsi1.BusinessLayer.DataLoad
};
};
_context.Sections.Add(section3);
_context.Sections.Add(section3);
 
var section4 = new Section
 
{
 
CourseId = -3,
 
Name = "General",
 
Order = 1,
 
SectionItems = new List<SectionItem>
 
{
 
new SectionItem
 
{
 
Order = 1,
 
SectionItemTypeId = sectionItemTypeForum.Id,
 
Forum = new Forum
 
{
 
Name = "Novedades"
 
}
 
},
 
new SectionItem
 
{
 
Order = 2,
 
SectionItemTypeId = sectionItemTypeForum.Id,
 
Forum = new Forum
 
{
 
Name = "General"
 
}
 
},
 
}
 
};
 
_context.Sections.Add(section4);
 
 
 
var section5 = new Section
 
{
 
CourseId = -11,
 
Name = "General",
 
Order = 1,
 
SectionItems = new List<SectionItem>
 
{
 
new SectionItem
 
{
 
Order = 1,
 
SectionItemTypeId = sectionItemTypeForum.Id,
 
Forum = new Forum
 
{
 
Name = "Novedades"
 
}
 
},
 
new SectionItem
 
{
 
Order = 2,
 
SectionItemTypeId = sectionItemTypeForum.Id,
 
Forum = new Forum
 
{
 
Name = "General"
 
}
 
},
 
}
 
};
 
_context.Sections.Add(section5);
 
 
var section6 = new Section
 
{
 
CourseId = -21,
 
Name = "General",
 
Order = 1,
 
SectionItems = new List<SectionItem>
 
{
 
new SectionItem
 
{
 
Order = 1,
 
SectionItemTypeId = sectionItemTypeForum.Id,
 
Forum = new Forum
 
{
 
Name = "Novedades"
 
}
 
},
 
new SectionItem
 
{
 
Order = 2,
 
SectionItemTypeId = sectionItemTypeForum.Id,
 
Forum = new Forum
 
{
 
Name = "General"
 
}
 
},
 
}
 
};
 
_context.Sections.Add(section6);
 
await _context.SaveChangesAsync();
await _context.SaveChangesAsync();
// ANSWER OPTIONS
// ANSWER OPTIONS
@@ -344,6 +675,209 @@ namespace Tsi1.BusinessLayer.DataLoad
@@ -344,6 +675,209 @@ namespace Tsi1.BusinessLayer.DataLoad
_context.AnswerOptions.AddRange(answerOptions);
_context.AnswerOptions.AddRange(answerOptions);
await _context.SaveChangesAsync();
await _context.SaveChangesAsync();
 
 
// Actividades
 
var activities = new List<Activity>
 
{
 
new Activity
 
{
 
CourseId = -1,
 
Date = new DateTime(2020, 12, 19),
 
IsVideoConference = false,
 
Name = "Primer Parcial",
 
Evaluation = new Evaluation
 
{
 
EvaluationTypeId = midTermEvaluationType.Id,
 
}
 
},
 
 
new Activity
 
{
 
CourseId = -1,
 
Date = new DateTime(2020, 12, 28),
 
IsVideoConference = false,
 
Name = "Segundo Parcial",
 
Evaluation = new Evaluation
 
{
 
EvaluationTypeId = midTermEvaluationType.Id,
 
}
 
},
 
 
new Activity
 
{
 
CourseId = -2,
 
Date = new DateTime(2020, 12, 29),
 
IsVideoConference = false,
 
Name = "Examen",
 
Evaluation = new Evaluation
 
{
 
EvaluationTypeId = examEvaluationType.Id,
 
}
 
},
 
 
new Activity
 
{
 
CourseId = -3,
 
Date = new DateTime(2020, 12, 27),
 
IsVideoConference = false,
 
Name = "Examen",
 
Evaluation = new Evaluation
 
{
 
EvaluationTypeId = examEvaluationType.Id,
 
}
 
},
 
 
new Activity
 
{
 
CourseId = -11,
 
Date = new DateTime(2020, 12, 16),
 
IsVideoConference = false,
 
Name = "Primer Parcial",
 
Evaluation = new Evaluation
 
{
 
EvaluationTypeId = midTermEvaluationType.Id,
 
}
 
},
 
 
new Activity
 
{
 
CourseId = -11,
 
Date = new DateTime(2020, 12, 27),
 
IsVideoConference = false,
 
Name = "Segundo Parcial",
 
Evaluation = new Evaluation
 
{
 
EvaluationTypeId = midTermEvaluationType.Id,
 
}
 
},
 
 
new Activity
 
{
 
CourseId = -21,
 
Date = new DateTime(2020, 12, 24),
 
IsVideoConference = false,
 
Name = "Examen",
 
Evaluation = new Evaluation
 
{
 
EvaluationTypeId = examEvaluationType.Id,
 
}
 
},
 
 
};
 
 
_context.Activities.AddRange(activities);
 
await _context.SaveChangesAsync();
 
 
// SURVEYS
 
 
var surveys = new List<Survey>
 
{
 
new Survey
 
{
 
IsGlobal = true,
 
Name = "Encuesta Fing",
 
Tenant = tenantFing,
 
SurveyQuestions = new List<SurveyQuestion>
 
{
 
new SurveyQuestion
 
{
 
Question = "¿Opinión sobre la Facultad de Ingeniería?"
 
},
 
 
new SurveyQuestion
 
{
 
Question = "¿Opinion sobre las carreras de grado?"
 
},
 
 
new SurveyQuestion
 
{
 
Question = "¿Opinion sobre las carreras de posgrado?"
 
},
 
}
 
},
 
 
new Survey
 
{
 
IsGlobal = true,
 
Name = "Encuesta Fmed",
 
Tenant = tenantFmed,
 
SurveyQuestions = new List<SurveyQuestion>
 
{
 
new SurveyQuestion
 
{
 
Question = "¿Opinión sobre la Facultad de Medicina?"
 
},
 
 
new SurveyQuestion
 
{
 
Question = "¿Opinion sobre las carreras de grado?"
 
},
 
 
new SurveyQuestion
 
{
 
Question = "¿Opinion sobre las carreras de posgrado?"
 
},
 
}
 
},
 
};
 
 
_context.Surveys.AddRange(surveys);
 
await _context.SaveChangesAsync();
 
 
// Communications
 
 
var calculo1 = await _context.Courses.FirstOrDefaultAsync(x => x.Id == -1);
 
var gal1 = await _context.Courses.FirstOrDefaultAsync(x => x.Id == -2);
 
var fisica1 = await _context.Courses.FirstOrDefaultAsync(x => x.Id == -3);
 
var neuroCiencias = await _context.Courses.FirstOrDefaultAsync(x => x.Id == -11);
 
var cardiovascular = await _context.Courses.FirstOrDefaultAsync(x => x.Id == -21);
 
 
var communications = new List<Communication>
 
{
 
new Communication
 
{
 
IsGlobal = true,
 
Tenant = tenantFing,
 
Text = "La facultad permanecera cerrada el día 25/12/2020"
 
},
 
 
new Communication
 
{
 
IsGlobal = true,
 
Tenant = tenantFmed,
 
Text = "La facultad permanecera cerrada el día 01/01/2021"
 
},
 
 
new Communication
 
{
 
IsGlobal = false,
 
Course = calculo1,
 
Text = "Se suspende la clase del día 22/12/2020"
 
},
 
 
new Communication
 
{
 
IsGlobal = false,
 
Course = gal1,
 
Text = "Se suspende la clase del día 17/12/2020"
 
},
 
 
new Communication
 
{
 
IsGlobal = false,
 
Course = neuroCiencias,
 
Text = "Se suspende la clase del día 26/12/2020"
 
},
 
new Communication
 
{
 
IsGlobal = false,
 
Course = cardiovascular,
 
Text = "Se suspende la clase del día 23/12/2020"
 
},
 
};
 
 
_context.Communications.AddRange(communications);
 
await _context.SaveChangesAsync();
}
}
}
}
}
}
 
\ No newline at end of file
Loading