public bool DecentralizeUserWithGroups(int userID, List<int> groupIDList) { 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 groups & user var oldInGroupList = dataEntities.InGroups; foreach (var ingroup in oldInGroupList) { if (ingroup.UserID == userID) { dataEntities.InGroups.DeleteObject(ingroup); } } //Insert new data for groups & user foreach (var id in groupIDList) { var newInGroup = new Model.InGroup(); newInGroup.UserID = userID; newInGroup.GroupID = id; newInGroup.DateCreate = DateTime.Now; newInGroup.Active = true; dataEntities.InGroups.AddObject(newInGroup); } 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(); } } } }
public bool DecentralizeGroupWithApps(int groupID, List<int> appIDList) { 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 apps & groups var oldInRoleList = dataEntities.InRoles; foreach (var inrole in oldInRoleList) { if (inrole.GroupID == groupID) { dataEntities.InRoles.DeleteObject(inrole); } } //Insert new data for apps & groups foreach (var id in appIDList) { var newInRole = new Model.InRole(); newInRole.ApplicationID = id; newInRole.GroupID = groupID; newInRole.DateCreate = DateTime.Now; newInRole.Active = true; dataEntities.InRoles.AddObject(newInRole); } 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(); } } } }
public bool DecentralizeGroupWithPermission(int groupID, List<int> permissionIDList) { 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 permission & groups var oldFilePermissionList = dataEntities.FilePermissions; foreach (var filePermission in oldFilePermissionList) { if (filePermission.GroupID == groupID) { dataEntities.FilePermissions.DeleteObject(filePermission); } } //Insert new data for permission & groups foreach (var id in permissionIDList) { var per = dataEntities.Permissions.Single(p => p.PermissionID == id); var newFilePermission = new Model.FilePermission(); newFilePermission.PermissionID = id; newFilePermission.GroupID = groupID; newFilePermission.FolderPath = per.Name; dataEntities.FilePermissions.AddObject(newFilePermission); } 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(); } } } }
public int Add(WebPortal.Model.ToChuc_GiaoVien toChuc_GiaoVien) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToToChuc_GiaoVien(toChuc_GiaoVien); return dataEntities.SaveChanges(); } }
public int Add(Model.User user) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToUsers(user); return dataEntities.SaveChanges(); } }
public int Delete(WebPortal.Model.LoaiTin_Lv1 loaiTinLV1) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.DeleteObject(loaiTinLV1); return dataEntities.SaveChanges(); } }
public int Add(WebPortal.Model.LoaiTin_Lv1 loaiTinLV1) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToLoaiTin_Lv1(loaiTinLV1); return dataEntities.SaveChanges(); } }
public int Add(Model.Profile profile) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToProfiles(profile); return dataEntities.SaveChanges(); } }
/// <summary> /// Xoa Chuc Vu /// </summary> /// <param name="chucVu"></param> /// <returns>1:Thanh cong</returns> public int Delete(WebPortal.Model.ChucVu chucVu) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.DeleteObject(chucVu); return dataEntities.SaveChanges(); } }
/// <summary> /// Them mot ChucVu /// </summary> /// <param name="chucVu"></param> /// <returns>1:Thanh cong</returns> public int Add(WebPortal.Model.ChucVu chucVu) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToChucVus(chucVu); return dataEntities.SaveChanges(); } }
public int Add(Model.InGroup inGroup) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToInGroups(inGroup); return dataEntities.SaveChanges(); } }
public int Add(WebPortal.Model.GiaoVien giaoVien) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToGiaoViens(giaoVien); return dataEntities.SaveChanges(); } }
public int Delete(Model.Setting setting) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.DeleteObject(setting); return dataEntities.SaveChanges(); } }
public int Delete(WebPortal.Model.TaiNguyen taiNguyen) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.DeleteObject(taiNguyen); return dataEntities.SaveChanges(); } }
public int Delete(Model.Group group) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.DeleteObject(group); return dataEntities.SaveChanges(); } }
public int Add(Model.Setting setting) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToSettings(setting); return dataEntities.SaveChanges(); } }
public int Add(Model.Permission permission) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToPermissions(permission); return dataEntities.SaveChanges(); } }
public int Delete(Model.Permission permission) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.DeleteObject(permission); return dataEntities.SaveChanges(); } }
public int Delete(WebPortal.Model.TinTuc tinTuc) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.DeleteObject(tinTuc); return dataEntities.SaveChanges(); } }
public int Add(Model.InRole inRole) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToInRoles(inRole); return dataEntities.SaveChanges(); } }
public int Add(WebPortal.Model.TaiNguyen_TinTuc taiNguyen_TinTuc) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToTaiNguyen_TinTuc(taiNguyen_TinTuc); return dataEntities.SaveChanges(); } }
public int Add(WebPortal.Model.Application application) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToApplications(application); return dataEntities.SaveChanges(); } }
public bool DecentralizeToChucWithGiaoVien(int tcID, 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 oldTC_GVList = dataEntities.ToChuc_GiaoVien; foreach (var tcgv in oldTC_GVList) { if (tcgv.IDToChuc == tcID) { dataEntities.ToChuc_GiaoVien.DeleteObject(tcgv); } } //Insert new data for gv & tc foreach (var id in gvIDList) { var newGVTC = new Model.ToChuc_GiaoVien(); newGVTC.IDGiaoVien = id; newGVTC.IDToChuc = tcID; dataEntities.ToChuc_GiaoVien.AddObject(newGVTC); } 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(); } } } }
public int Delete(int idTaiNguyen) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { var taiNguyen = dataEntities.TaiNguyens.Single(tn => tn.IDTaiNguyen == idTaiNguyen); dataEntities.DeleteObject(taiNguyen); return dataEntities.SaveChanges(); } }
public int Add(WebPortal.Model.TaiNguyen taiNguyen) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToTaiNguyens(taiNguyen); dataEntities.SaveChanges(); return taiNguyen.IDTaiNguyen; } }
public int Delete(WebPortal.Model.ToChuc toChuc) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.Attach(toChuc);//hue dataEntities.DeleteObject(toChuc); return dataEntities.SaveChanges(); } }
public int Delete(WebPortal.Model.Application application) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.Attach(application); dataEntities.DeleteObject(application); return dataEntities.SaveChanges(); } }
public int Delete(int groupID) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { Model.Group currentG = dataEntities.Groups.Single(a => a.GroupID == groupID); currentG.Active = false; return dataEntities.SaveChanges(); } }
public int Delete(int id) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { var news = dataEntities.TinTucs.Single(tt => tt.IDTinTuc == id); dataEntities.DeleteObject(news); return dataEntities.SaveChanges(); } }
public int Add(WebPortal.Model.TinTuc tinTuc) { using (WebPortalEntities dataEntities = new WebPortalEntities()) { dataEntities.AddToTinTucs(tinTuc); dataEntities.SaveChanges(); int idTinTuc= tinTuc.IDTinTuc; return idTinTuc; } }