Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add email field for student in the complete UI #27

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MarkMe.Core/DTOs/StudentDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class StudentDTO
public string RegistrationNo { get; set; }
public string Session { get; set; }
public string Section { get; set; }
public string Email { get; set; }
}
public class CreateStudentDTO
{
Expand All @@ -26,5 +27,6 @@ public class CreateStudentDTO
public string RegistrationNo { get; set; }
public string Session { get; set; }
public string Section { get; set; }
public string Email { get; set; }
}
}
6 changes: 3 additions & 3 deletions MarkMe.Core/Repositories/StudentRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class StudentRepository(IDatabase _database) : IStudentRepository

public async Task<StudentDTO> AddStudentAsync(StudentDTO obj)
{
var sql = "INSERT INTO Students (CollegeRollNo, UniversityRollNo, RegistrationNo, FirstName, LastName, Session, Section, IsDeleted) " +
"VALUES (@CollegeRollNo, @UniversityRollNo, @RegistrationNo, @FirstName, @LastName, @Session, @Section, 0); " +
var sql = "INSERT INTO Students (CollegeRollNo, UniversityRollNo, RegistrationNo, FirstName, LastName, Session, Section, IsDeleted, Email) " +
"VALUES (@CollegeRollNo, @UniversityRollNo, @RegistrationNo, @FirstName, @LastName, @Session, @Section, 0, @Email); " +
"SELECT SCOPE_IDENTITY()";

obj.StudentId = await _database.QuerySingleAsync<int>(sql, parameters: obj);
Expand Down Expand Up @@ -71,7 +71,7 @@ FROM ClassRepresentatives
UPDATE Students
SET
CollegeRollNo = @CollegeRollNo, UniversityRollNo = @UniversityRollNo, RegistrationNo = @RegistrationNo,
FirstName = @FirstName, LastName = @LastName, Session = @Session, Section = @Section
FirstName = @FirstName, LastName = @LastName, Session = @Session, Section = @Section, Email = @Email
WHERE StudentId = @StudentId;

SELECT * FROM Students WHERE StudentId = @StudentId
Expand Down
3 changes: 2 additions & 1 deletion MarkMe.Core/Services/StudentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public async Task<StudentDTO> AddAsync(CreateStudentDTO obj)
FirstName = obj.FirstName,
LastName = obj.LastName,
Session = obj.Session,
Section = obj.Section
Section = obj.Section,
Email = obj.Email
};
var stcd = await _studRepo.AddStudentAsync(student);
return stcd;
Expand Down
177 changes: 96 additions & 81 deletions MarkMe.Database/AppDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070982",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -65,6 +66,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070943",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -76,6 +78,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070944",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -87,6 +90,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070945",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -98,6 +102,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070946",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -109,6 +114,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070947",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -120,6 +126,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070948",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -131,6 +138,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070949",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -142,6 +150,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070950",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -153,6 +162,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070951",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -164,6 +174,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070952",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -175,6 +186,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070953",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -186,6 +198,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070954",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -197,6 +210,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070955",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
new Student() {
Expand All @@ -208,6 +222,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
UniversityRollNo="070956",
Section="G1",
Session="20212025",
Email = "[email protected]",
IsDeleted = false
},
});
Expand Down Expand Up @@ -305,87 +320,87 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
}
});

// Class Representatives
modelBuilder.Entity<ClassRepresentative>().HasData(new[]
{
new ClassRepresentative
{
StudentId = 1,
CourseId = 1,
NominatedBy = 1,
IsDeleted = 0
},
new ClassRepresentative
{
StudentId = 2,
CourseId = 2,
NominatedBy = 1,
IsDeleted = 0
},
new ClassRepresentative
{
StudentId = 2,
CourseId = 1,
NominatedBy = 1,
IsDeleted = 0
},
new ClassRepresentative
{
StudentId = 2,
CourseId = 3,
NominatedBy = 1,
IsDeleted = 0
},
new ClassRepresentative
{
StudentId = 2,
CourseId = 4,
NominatedBy = 1,
IsDeleted = 0
},
new ClassRepresentative
{
StudentId = 2,
CourseId = 5,
NominatedBy = 1,
IsDeleted = 0
},
new ClassRepresentative
{
StudentId = 3,
CourseId = 3,
NominatedBy = 1,
IsDeleted = 0
},
new ClassRepresentative
{
StudentId = 4,
CourseId = 4,
NominatedBy = 1,
IsDeleted = 0
},
new ClassRepresentative
{
StudentId = 5,
CourseId = 5,
NominatedBy = 1,
IsDeleted = 0
},
new ClassRepresentative
{
StudentId = 6,
CourseId = 1,
NominatedBy = 1,
IsDeleted = 0
},
new ClassRepresentative
{
StudentId = 7,
CourseId = 2,
NominatedBy = 1,
IsDeleted = 0,
}
});
//// Class Representatives
//modelBuilder.Entity<ClassRepresentative>().HasData(new[]
//{
// new ClassRepresentative
// {
// StudentId = 1,
// CourseId = 1,
// NominatedBy = 1,
// IsDeleted = 0
// },
// new ClassRepresentative
// {
// StudentId = 2,
// CourseId = 2,
// NominatedBy = 1,
// IsDeleted = 0
// },
// new ClassRepresentative
// {
// StudentId = 2,
// CourseId = 1,
// NominatedBy = 1,
// IsDeleted = 0
// },
// new ClassRepresentative
// {
// StudentId = 2,
// CourseId = 3,
// NominatedBy = 1,
// IsDeleted = 0
// },
// new ClassRepresentative
// {
// StudentId = 2,
// CourseId = 4,
// NominatedBy = 1,
// IsDeleted = 0
// },
// new ClassRepresentative
// {
// StudentId = 2,
// CourseId = 5,
// NominatedBy = 1,
// IsDeleted = 0
// },
// new ClassRepresentative
// {
// StudentId = 3,
// CourseId = 3,
// NominatedBy = 1,
// IsDeleted = 0
// },
// new ClassRepresentative
// {
// StudentId = 4,
// CourseId = 4,
// NominatedBy = 1,
// IsDeleted = 0
// },
// new ClassRepresentative
// {
// StudentId = 5,
// CourseId = 5,
// NominatedBy = 1,
// IsDeleted = 0
// },
// new ClassRepresentative
// {
// StudentId = 6,
// CourseId = 1,
// NominatedBy = 1,
// IsDeleted = 0
// },
// new ClassRepresentative
// {
// StudentId = 7,
// CourseId = 2,
// NominatedBy = 1,
// IsDeleted = 0,
// }
//});

// Activities
modelBuilder.Entity<Activity>().HasData(new[]
Expand Down
3 changes: 3 additions & 0 deletions MarkMe.Database/Entities/Student.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class Student
[StringLength(50)]
public string LastName { get; set; } = string.Empty;

[EmailAddress]
public string Email { get; set; } = string.Empty;

[StringLength(9, ErrorMessage = "Session cannot be longer than 9 characters.")]
public string Session { get; set; } = string.Empty;

Expand Down
Loading