private static CourseModel ConvertToCourse(Dictionary <string, string> fieldValues) { CourseModel c = new CourseModel(); foreach (KeyValuePair <string, string> row in fieldValues) { switch (row.Key) { case "id": try { c.CourseId = int.Parse(row.Value); } catch (Exception) { throw; } break; case "code": c.CourseCode = row.Value; break; case "name": c.CourseName = row.Value; break; case "NQFLevel": try { c.NQFLevel = int.Parse(row.Value); } catch (Exception) { throw; } break; case "CourseDescription": c.CourseDescription = row.Value; break; default: break; } } return(c); }
private List <string> ConvertToColumnValues(CourseModel c) { List <string> colValues = new List <string>(); try { colValues.Add("'" + c.CourseCode + "'"); colValues.Add("'" + c.CourseName + "'"); colValues.Add(c.NQFLevel.ToString()); colValues.Add("'" + c.CourseDescription + "'"); } catch (Exception) { throw; } return(colValues); }