//Saves the module data to the database using the module object public static void saveModule(DataRow row, CSResults.DAL.ModuleContext context) { Models.Module md = new Models.Module() { moduleID = row["Module Code"].ToString(), moduleName = row["Module Name"].ToString() }; //Adds the module name and code if it does not exist in the databse context.Module.AddOrUpdate(x => x.moduleID, md); context.SaveChanges(); }
//Saves the results data to the database using the result object public static void saveResult(DataRow row, CSResults.DAL.ModuleContext context, IDictionary <string, string> dict) { Result res = new Result(); foreach (var item in dict) { //Gets the data and the resulting property name from the dictionary string data = row[item.Key].ToString(); string resProp = item.Value; setProp(res, resProp, data); } //Adds the module results if it does not exist in the databse context.Result.AddOrUpdate(x => new { x.moduleID, x.year }, res); context.SaveChanges(); }