//Polymorphic public override void CreateStudent(Student st) { try { var check = from s in db.Students where s.Username == st.Username select s; if (check.Count() == 0) { db.Students.Add(st); db.SaveChanges(); } else { throw new Exception("Username is already in use, please select another"); } } catch (Exception ex) { throw new Exception("New student was not created" + ": " + ex.Message); } }
public void Insert(Registration entity) { _dbContext.Add(entity); _dbContext.SaveChanges(); }