public void AddTa(POCO.Ta ta, ref List<string> errors) { var db_Ta = new TeachingAssistant(); try { db_Ta.ta_type_id = int.Parse(ta.TaType); db_Ta.first = ta.FirstName; db_Ta.last = ta.LastName; this.context.TeachingAssistants.Add(db_Ta); this.context.SaveChanges(); } catch (Exception e) { errors.Add("Error occured in TaRepository.AddTa: " + e); } }
public bool IsNotDuplicateTa(Ta ta, ref List<string> errors) { var db_Ta = new TeachingAssistant(); try { var ta_Type = int.Parse(ta.TaType); var isDuplicate = this.context.TeachingAssistants.Where( x => x.first == ta.FirstName && x.last == ta.LastName && x.ta_type_id == ta_Type).Count() > 0; if (isDuplicate) { return false; } else { return true; } } catch (Exception e) { errors.Add("Error occured in TaRepository.IsDuplicateTa: " + e); } return false; }
public void RemoveTa(int ta_id, ref List<string> errors) { var db_Ta = new TeachingAssistant(); try { db_Ta = this.context.TeachingAssistants.Find(ta_id); db_Ta = this.context.TeachingAssistants.Remove(db_Ta); this.context.SaveChanges(); } catch (Exception e) { errors.Add("Error occured in TaRepository.RemoveTa: " + e); } }
////good method for validation when adding new course public bool IsDuplicateCourse(POCO.Ta ta, ref List<string> errors) { var db_Ta = new TeachingAssistant(); try { db_Ta = this.context.TeachingAssistants.Find(db_Ta); if (db_Ta == null) { return true; } else { return false; } } catch (Exception e) { errors.Add("Error occured in TaRepository.IsDuplicateCourse: " + e); } return true; }