Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tsi1-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rodrigo Sastre Marotta
tsi1-backend
Commits
821ed085
Commit
821ed085
authored
4 years ago
by
esantangelo
Browse files
Options
Downloads
Patches
Plain Diff
fix data load
parent
96e644a4
No related branches found
No related tags found
1 merge request
!26
Develop
Pipeline
#10359
passed
4 years ago
Stage: external
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs
+282
-250
282 additions, 250 deletions
Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs
with
282 additions
and
250 deletions
Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs
+
282
−
250
View file @
821ed085
...
...
@@ -36,256 +36,288 @@ namespace Tsi1.BusinessLayer.DataLoad
public
async
Task
LoadDataAsync
()
{
//// TENANTS
//var adminTenant = new TenantCreateDto
//{
// Name = TenantAdmin.Name,
//};
//var adminTenantId = await _tenantService.Create(adminTenant);
//var fingTenant = new TenantCreateDto
//{
// Name = "fing",
//};
//var fingTenantId = await _tenantService.Create(fingTenant);
//// USER TYPES
//var udelarAdminUserType = new UserType
//{
// Name = UserTypes.UdelarAdmin,
//};
//_context.Add(udelarAdminUserType);
//var facultyAdminUserType = new UserType
//{
// Name = UserTypes.FacultyAdmin,
//};
//_context.Add(facultyAdminUserType);
//var professorUserType = new UserType
//{
// Name = UserTypes.Professor,
//};
//_context.Add(professorUserType);
//var studentUserType = new UserType
//{
// Name = UserTypes.Student,
//};
//_context.Add(studentUserType);
//await _context.SaveChangesAsync();
//// USERS
//var userAdminUdelar = new UserRegisterDto
//{
// UserTypeId = udelarAdminUserType.Id,
// Username = "admin",
// Password = "admin",
// FirstName = "admin",
// LastName = "admin",
// Email = "admin@mail.com",
// IdentityCard = "12345678-9",
// Age = 44
//};
//await _userService.Create(userAdminUdelar, udelarAdminUserType.Name, adminTenantId.Data.Id);
//var userStudent1 = new UserRegisterDto
//{
// UserTypeId = studentUserType.Id,
// Username = "enzo",
// Password = "enzo",
// FirstName = "Enzo",
// LastName = "Santangelo",
// Email = "enzo@mail.com",
// IdentityCard = "13242344-5",
// Age = 25
//};
//await _userService.Create(userStudent1, studentUserType.Name, fingTenantId.Data.Id);
//var userStudent2 = new UserRegisterDto
//{
// UserTypeId = studentUserType.Id,
// Username = "mathias",
// Password = "mathias",
// FirstName = "Mathias",
// LastName = "Martinez",
// Email = "mathias@mail.com",
// IdentityCard = "3782346-5",
// Age = 26
//};
//await _userService.Create(userStudent2, studentUserType.Name, fingTenantId.Data.Id);
//var userProfessor = new UserRegisterDto
//{
// UserTypeId = professorUserType.Id,
// Username = "prof1",
// Password = "prof1",
// FirstName = "Juan",
// LastName = "Perez",
// Email = "jp@mail.com",
// IdentityCard = "98754342-5",
// Age = 34
//};
//await _userService.Create(userProfessor, professorUserType.Name, fingTenantId.Data.Id);
//var userFingAdmin = new UserRegisterDto
//{
// UserTypeId = facultyAdminUserType.Id,
// Username = "fing",
// Password = "fing",
// FirstName = "fing",
// LastName = "fing",
// Email = "fing@mail.com",
// IdentityCard = "89547821-5",
// Age = 45
//};
//await _userService.Create(userFingAdmin, facultyAdminUserType.Name, fingTenantId.Data.Id);
//// SECTION ITEM TYPES
//var sectionItemTypeFile = new SectionItemType
//{
// Name = SectionItemTypes.File,
//};
//_context.SectionItemTypes.Add(sectionItemTypeFile);
//var sectionItemTypeForum = new SectionItemType
//{
// Name = SectionItemTypes.Forum,
//};
//_context.SectionItemTypes.Add(sectionItemTypeForum);
//var sectionItemTypeSurvey = new SectionItemType
//{
// Name = SectionItemTypes.Survey,
//};
//_context.SectionItemTypes.Add(sectionItemTypeSurvey);
//await _context.SaveChangesAsync();
//// COURSES
//var course1Dto = new CourseCreateDto
//{
// Name = "Calculo 1",
// TenantId = fingTenantId.Data.Id
//};
//var course1 = await _courseService.Create(course1Dto);
//var course2Dto = new CourseCreateDto
//{
// Name = "GAL 1",
// TenantId = fingTenantId.Data.Id
//};
//var course2 = await _courseService.Create(course2Dto);
//var course3Dto = new CourseCreateDto
//{
// Name = "Fisica 1",
// TenantId = fingTenantId.Data.Id
//};
//await _courseService.Create(course3Dto);
//// SECTIONS
//var section1 = new SectionCreateDto
//{
// CourseId = course1.Data.Id,
// Name = "General",
// Order = 1
//};
//var section1Id = await _sectionService.Create(section1);
//var section2 = new SectionCreateDto
//{
// CourseId = course2.Data.Id,
// Name = "General",
// Order = 1
//};
//var section2Id = await _sectionService.Create(section2);
//var section3 = new SectionCreateDto
//{
// CourseId = course1.Data.Id,
// Name = "Tema 1",
// Order = 2
//};
//var section3Id = await _sectionService.Create(section3);
//// SECTION ITEMS
//var sectionItem1 = new SectionItemCreateDto
//{
// SectionId = section1Id.Data,
// Order = 1,
// SectionItemTypeId = sectionItemTypeForum.Id,
// Forum = new ForumCreateDto
// {
// Name = "Novedades"
// }
//};
//await _sectionItemService.Create(sectionItem1);
//var sectionItem2 = new SectionItemCreateDto
//{
// SectionId = section2Id.Data,
// Order = 1,
// SectionItemTypeId = sectionItemTypeForum.Id,
// Forum = new ForumCreateDto
// {
// Name = "Novedades"
// }
//};
//await _sectionItemService.Create(sectionItem2);
//var sectionItem3 = new SectionItemCreateDto
//{
// SectionId = section1Id.Data,
// Order = 2,
// SectionItemTypeId = sectionItemTypeForum.Id,
// Forum = new ForumCreateDto
// {
// Name = "General"
// }
//};
//await _sectionItemService.Create(sectionItem3);
//var sectionItem4 = new SectionItemCreateDto
//{
// SectionId = section3Id.Data,
// Order = 1,
// SectionItemTypeId = sectionItemTypeForum.Id,
// Forum = new ForumCreateDto
// {
// Name = "Tema 1"
// }
//};
//await _sectionItemService.Create(sectionItem4);
//// ANSWER OPTIONS
//var answerOptions = new List<AnswerOption>
//{
// new AnswerOption
// {
// Name = "Excelente"
// },
// new AnswerOption
// {
// Name = "Conforme"
// },
// new AnswerOption
// {
// Name = "Neutro"
// },
// new AnswerOption
// {
// Name = "No Conforme"
// },
// new AnswerOption
// {
// Name = "Mal"
// },
//};
//_context.AnswerOptions.AddRange(answerOptions);
//await _context.SaveChangesAsync();
// TENANTS
var
tenants
=
new
List
<
Tenant
>
{
new
Tenant
{
Name
=
TenantAdmin
.
Name
,
},
new
Tenant
{
Name
=
"fing"
,
},
};
_context
.
Tenants
.
AddRange
(
tenants
);
await
_context
.
SaveChangesAsync
();
// USER TYPES
var
udelarAdminUserType
=
new
UserType
{
Name
=
UserTypes
.
UdelarAdmin
,
};
_context
.
Add
(
udelarAdminUserType
);
var
facultyAdminUserType
=
new
UserType
{
Name
=
UserTypes
.
FacultyAdmin
,
};
_context
.
Add
(
facultyAdminUserType
);
var
professorUserType
=
new
UserType
{
Name
=
UserTypes
.
Professor
,
};
_context
.
Add
(
professorUserType
);
var
studentUserType
=
new
UserType
{
Name
=
UserTypes
.
Student
,
};
_context
.
Add
(
studentUserType
);
await
_context
.
SaveChangesAsync
();
// USERS
var
users
=
new
List
<
User
>
{
new
User
{
UserTypeId
=
udelarAdminUserType
.
Id
,
Username
=
"admin"
,
Password
=
"admin"
,
FirstName
=
"admin"
,
LastName
=
"admin"
,
Email
=
"admin@mail.com"
,
TenantId
=
1
,
},
new
User
{
UserTypeId
=
studentUserType
.
Id
,
Username
=
"enzo"
,
Password
=
"enzo"
,
FirstName
=
"Enzo"
,
LastName
=
"Santangelo"
,
Email
=
"enzo@mail.com"
,
Student
=
new
Student
{
TenantId
=
2
,
IdentityCard
=
"13242344-5"
,
Age
=
25
},
TenantId
=
2
,
},
new
User
{
UserTypeId
=
studentUserType
.
Id
,
Username
=
"mathias"
,
Password
=
"mathias"
,
FirstName
=
"Mathias"
,
LastName
=
"Martinez"
,
Email
=
"mathias@mail.com"
,
Student
=
new
Student
{
IdentityCard
=
"3782346-5"
,
TenantId
=
2
,
Age
=
26
},
TenantId
=
2
,
},
new
User
{
UserTypeId
=
professorUserType
.
Id
,
Username
=
"prof1"
,
Password
=
"prof1"
,
FirstName
=
"Juan"
,
LastName
=
"Perez"
,
Email
=
"jp@mail.com"
,
Professor
=
new
Professor
{
TenantId
=
2
,
IdentityCard
=
"98754342-5"
,
},
TenantId
=
2
,
},
new
User
{
UserTypeId
=
facultyAdminUserType
.
Id
,
Username
=
"fing"
,
Password
=
"fing"
,
FirstName
=
"fing"
,
LastName
=
"fing"
,
Email
=
"fing@mail.com"
,
TenantId
=
2
,
},
};
_context
.
Users
.
AddRange
(
users
);
try
{
await
_context
.
SaveChangesAsync
();
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
ex
.
Message
);
}
// SECTION ITEM TYPES
var
sectionItemTypeFile
=
new
SectionItemType
{
Name
=
SectionItemTypes
.
File
,
};
_context
.
SectionItemTypes
.
Add
(
sectionItemTypeFile
);
var
sectionItemTypeForum
=
new
SectionItemType
{
Name
=
SectionItemTypes
.
Forum
,
};
_context
.
SectionItemTypes
.
Add
(
sectionItemTypeForum
);
var
sectionItemTypeSurvey
=
new
SectionItemType
{
Name
=
SectionItemTypes
.
Survey
,
};
_context
.
SectionItemTypes
.
Add
(
sectionItemTypeSurvey
);
await
_context
.
SaveChangesAsync
();
// COURSES
var
courses
=
new
List
<
Course
>
{
new
Course
{
Id
=
1
,
Name
=
"Calculo 1"
,
TenantId
=
2
},
new
Course
{
Id
=
2
,
Name
=
"GAL 1"
,
TenantId
=
2
},
new
Course
{
Id
=
3
,
Name
=
"Fisica 1"
,
TenantId
=
2
}
};
_context
.
Courses
.
AddRange
(
courses
);
await
_context
.
SaveChangesAsync
();
// SECTIONS
var
section1
=
new
Section
{
CourseId
=
1
,
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
(
section1
);
var
section2
=
new
Section
{
CourseId
=
2
,
Name
=
"General"
,
Order
=
1
,
SectionItems
=
new
List
<
SectionItem
>
{
new
SectionItem
{
Order
=
1
,
SectionItemTypeId
=
sectionItemTypeForum
.
Id
,
Forum
=
new
Forum
{
Name
=
"Novedades"
}
}
}
};
_context
.
Sections
.
Add
(
section2
);
var
section3
=
new
Section
{
CourseId
=
1
,
Name
=
"Tema 1"
,
Order
=
2
,
SectionItems
=
new
List
<
SectionItem
>
{
new
SectionItem
{
Order
=
1
,
SectionItemTypeId
=
sectionItemTypeForum
.
Id
,
Forum
=
new
Forum
{
Name
=
"Tema 1"
}
}
}
};
_context
.
Sections
.
Add
(
section3
);
await
_context
.
SaveChangesAsync
();
// ANSWER OPTIONS
var
answerOptions
=
new
List
<
AnswerOption
>
{
new
AnswerOption
{
Name
=
"Excelente"
},
new
AnswerOption
{
Name
=
"Conforme"
},
new
AnswerOption
{
Name
=
"Neutro"
},
new
AnswerOption
{
Name
=
"No Conforme"
},
new
AnswerOption
{
Name
=
"Mal"
},
};
_context
.
AnswerOptions
.
AddRange
(
answerOptions
);
await
_context
.
SaveChangesAsync
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment