public void AddAdmin(POCO.Admin pocoAdmin, ref List<string> errors) { admin db_Admin = new admin(); try { db_Admin.First = pocoAdmin.FirstName; db_Admin.Last = pocoAdmin.LastName; this.context.admins.Add(db_Admin); this.context.SaveChanges(); } catch (Exception e) { errors.Add("Error occured in AdminRepository.AddAdminById: " + e); } }
////good method for validation when adding new course public bool IsNotDuplicateAdmin(POCO.Admin adminPoco, ref List<string> errors) { var db_Admin = new admin(); try { db_Admin = this.context.admins.Find(db_Admin); if (db_Admin == null) { return true; } else { return false; } } catch (Exception e) { errors.Add("Error occured in AdminRepository.IsDuplicateAdmin: " + e); } return true; }
public void UpdateAdmin(POCO.Admin adminPoco, ref List<string> errors) { var db_Admin = new admin(); try { db_Admin = this.context.admins.Find(adminPoco.Id); db_Admin.First = adminPoco.FirstName; db_Admin.Last = adminPoco.LastName; this.context.SaveChanges(); } catch (Exception e) { errors.Add("Error occured in AdminRepository.UpdateAdmin: " + e); } }
public void RemoveAdmin(int admin_id, ref List<string> errors) { var db_Admin = new admin(); try { db_Admin.admin_id = admin_id; db_Admin = this.context.admins.Remove(db_Admin); this.context.SaveChanges(); } catch (Exception e) { errors.Add("Error occured in TaRepository.FindTaById: " + e); } }