private void SaveStudent(Student model) { var userId = 0; var user = new User { UserName = model.Email, Password = model.MatricNo, CreatedBy = model.FirstName, CreatedDate = DateTime.Now }; if (user == null) { _db.Users.Add(user); userId = _db.SaveChanges(); } model.UserId = userId; if (_db.Entry <Student>(model).State == EntityState.Detached) { _db.Set <Student>().Attach(model); } _db.Entry(model).State = EntityState.Modified; _db.SaveChanges(); preenrollmentFmds.Clear(); picBoxFingerPrint.Image = null; count = 0; lblCount.Invoke(new Action(() => { lblCount.Text = count.ToString(); })); }
public void Add <T>(T item) where T : class { context.Set <T>().Add(item); context.SaveChanges(); }
public EntityGeneric(DataEntity context) { this.context = context; this.dbSet = context.Set <T>(); }