List all the training registrations for all the courses. The
following information should be displayed.
✓ A list of all courses and their training registrations. After every course training iteration, display a list of
all delegates registered with all their relevant details (e.g address, dietary options etc )
Please ensure that your lab meet the below technology requirements.
✓ The Application should be in a source version control repository e.g GitHub ,GitLab, Bitbucket, Microsoft's
Azure DevOps etc .
✓ Use Entity framework (EF) code first approach or database first approach.
✓ If you chose code first approach use Entity framework (EF) migration to propagate your database
(or to deploy your changes to the database).
✓ Use Entity Framework and Linq to retrieve all the required information that need to be displayed.
✓ Use any plugin / library to read the excel document “Training.xlsx”.
Bonus Task
The application should be able to register a delegate for training
What I have tried:
static void Main(string[] args)
{
FileInfo existingFile = new FileInfo(@"C:\Users\tshilidzi.nembilwi\Downloads\WORK STUFF\DATABASE TASK\Training.xlsx");
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
DataTableCollection tableCollection;
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
using (var stream = File.Open(existingFile.FullName, FileMode.Open, FileAccess.Read))
{
using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
{
DataSet result = reader.AsDataSet(new ExcelDataSetConfiguration()
{
ConfigureDataTable = (_) => new ExcelDataTableConfiguration() { UseHeaderRow = true }
});
tableCollection = result.Tables;
foreach (System.Data.DataColumn table in tableCollection[0].Columns)
{
Console.WriteLine(table);
}
}
}
DataTable dt = tableCollection[0];
AdaptItAcaDataContext dbContext = new AdaptItAcaDataContext();
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
Delegate dl = new Delegate();
dl.FirstName = dt.Rows[i]["FirstName"].ToString();
dl.LastName = dt.Rows[i]["LastName"].ToString();
dl.PhoneNumber = (dt.Rows[i]["PhoneNumber"].ToString());
dl.Email = (dt.Rows[i]["Email"].ToString());
dl.CompanyName = (dt.Rows[i]["CompanyName"].ToString());
dl.DietaryRequirement = (dt.Rows[i]["DietaryRequirement"].ToString());
dbContext.Delegates.InsertOnSubmit(dl);
dbContext.SubmitChanges();
Course cs = new Course();
cs.CourseCode = dt.Rows[i]["Course Code"].ToString();
cs.CourseName = dt.Rows[i]["Course Name"].ToString();
cs.CourseDescription = (dt.Rows[i]["Course Description"].ToString());
dbContext.Courses.InsertOnSubmit(cs);
dbContext.SubmitChanges();
}
}
Console.ReadKey();
}
}
}