public bool DecentralizeChucVuWithGiaoVien(int cvID, List<int> gvIDList)
        {
            DbTransaction dbTransaction = null;
            using (WebPortalEntities dataEntities = new WebPortalEntities())
            {
                try
                {
                    if (dataEntities.Connection.State == System.Data.ConnectionState.Closed)
                    {
                        dataEntities.Connection.Open();
                    }
                    dbTransaction = dataEntities.Connection.BeginTransaction();

                    //Delete old data for gv & tc
                    var oldCV_GVList = dataEntities.ChucVu_GiaoVien;
                    foreach (var cvgv in oldCV_GVList)
                    {
                        if (cvgv.IDChucVu == cvID)
                        {
                            dataEntities.ChucVu_GiaoVien.DeleteObject(cvgv);
                        }
                    }

                    //Insert new data for gv & tc
                    foreach (var id in gvIDList)
                    {
                        var newGVCV = new Model.ChucVu_GiaoVien();
                        newGVCV.IDGiaoVien = id;
                        newGVCV.IDChucVu = cvID;
                        dataEntities.ChucVu_GiaoVien.AddObject(newGVCV);
                    }

                    if (dataEntities.SaveChanges() != 0)
                    {
                        dbTransaction.Commit();
                        return true;
                    }
                    else
                    {
                        dbTransaction.Rollback();
                        return false;
                    }
                }
                catch
                {
                    dbTransaction.Rollback();
                    return false;
                }
                finally
                {
                    if (dataEntities.Connection.State == System.Data.ConnectionState.Open)
                    {
                        dataEntities.Connection.Close();
                    }
                }
            }
        }
 /// <summary>
 /// Create a new ChucVu_GiaoVien object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static ChucVu_GiaoVien CreateChucVu_GiaoVien(global::System.Int32 id)
 {
     ChucVu_GiaoVien chucVu_GiaoVien = new ChucVu_GiaoVien();
     chucVu_GiaoVien.ID = id;
     return chucVu_GiaoVien;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the ChucVu_GiaoVien EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToChucVu_GiaoVien(ChucVu_GiaoVien chucVu_GiaoVien)
 {
     base.AddObject("ChucVu_GiaoVien", chucVu_GiaoVien);
 }