Esempio n. 1
0
 public Model.Profile Single(int profileID)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Profiles.Single(pro => pro.ProfileID == profileID);
     }
 }
Esempio n. 2
0
 public List<Model.Profile> AllByUserID(int userID)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Profiles.Where(pro => pro.UserID == userID && pro.Active == true).ToList();
     }
 }
Esempio n. 3
0
 public List<Model.Profile> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Profiles.Where(p => p.Active == true).ToList();
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Lay tac ca ChucVu hien co
 /// </summary>
 /// <returns>List<ChucVu></returns>
 public List<WebPortal.Model.ChucVu> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.ChucVus.ToList();
     }
 }
Esempio n. 5
0
 public List<WebPortal.Model.ChucVu_GiaoVien> chucvu(int idGiaoVien)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.ChucVu_GiaoVien.Where(app => app.IDGiaoVien == idGiaoVien).ToList();
     }
 }
Esempio n. 6
0
 public List<Model.InRole> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.InRoles.ToList();
     }
 }
Esempio n. 7
0
 public Model.Setting Single(int settingID)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Settings.Single(setting => setting.SettingID == settingID);
     }
 }
Esempio n. 8
0
 public WebPortal.Model.ToChuc Single(int idToChuc)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.ToChucs.Single(app => app.IDToChuc == idToChuc);
     }
 }
Esempio n. 9
0
 public List<WebPortal.Model.ToChuc_GiaoVien> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.ToChuc_GiaoVien.ToList();
     }
 }
Esempio n. 10
0
 public List<Model.User> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Users.Where(user => user.Active == true).ToList();
     }
 }
Esempio n. 11
0
 public List<WebPortal.Model.TaiNguyen> Paging(int start, int numberRecords)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.TaiNguyens.Skip(start).Take(numberRecords).ToList();
     }
 }
Esempio n. 12
0
 public List<Model.Group> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Groups.Where(gr => gr.Active == true).ToList();
     }
 }
Esempio n. 13
0
 public List<Model.Setting> Paging(int start, int numberRecords)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Settings.Skip(start).Take(numberRecords).ToList();
     }
 }
Esempio n. 14
0
 public List<Model.Permission> Get_All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Permissions.ToList();
     }
 }
Esempio n. 15
0
 public List<WebPortal.Model.TaiNguyen_TinTuc> LayTaiNguyenTheoTin(int idTinTuc)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.TaiNguyen_TinTuc.Where(app => app.IDTinTuc == idTinTuc).ToList();
     }
 }
Esempio n. 16
0
 public List<Model.Permission> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Permissions.Where(per=>per.Active==true).ToList();
     }
 }
Esempio n. 17
0
 public WebPortal.Model.TaiNguyen Single(int idTaiNguyen)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.TaiNguyens.Single(app => app.IDTaiNguyen == idTaiNguyen);
     }
 }
Esempio n. 18
0
 public List<WebPortal.Model.TinTuc> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.TinTucs.ToList();
     }
 }
Esempio n. 19
0
 public List<WebPortal.Model.TaiNguyen> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.TaiNguyens.ToList();
     }
 }
Esempio n. 20
0
 public List<WebPortal.Model.LoaiTin_Lv1> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.LoaiTin_Lv1.ToList();
     }
 }
Esempio n. 21
0
 public List<Model.Group> Get_All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Groups.ToList();
     }
 }
Esempio n. 22
0
 public List<WebPortal.Model.GiaoVien> Paging(int start, int numberRecords)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.GiaoViens.OrderBy(gv => gv.IDGiaoVien).Skip(start).Take(numberRecords).ToList();
     }
 }
Esempio n. 23
0
 public List<Model.Setting> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Settings.ToList();
     }
 }
Esempio n. 24
0
 public List<WebPortal.Model.TinTuc> Paging(int start, int numberRecords,List<WebPortal.Model.TinTuc> listTin)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return listTin.OrderByDescending(tt => tt.IDTinTuc).Skip(start).Take(numberRecords).ToList();
     }
 }
Esempio n. 25
0
        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();
                    }
                }
            }
        }
Esempio n. 26
0
        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();
                    }
                }
            }
        }
Esempio n. 27
0
        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();
                    }
                }
            }
        }
Esempio n. 28
0
 public int Delete(Model.Setting setting)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         dataEntities.DeleteObject(setting);
         return dataEntities.SaveChanges();
     }
 }
Esempio n. 29
0
 public int Delete(Model.Permission permission)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         dataEntities.DeleteObject(permission);
         return dataEntities.SaveChanges();
     }
 }
Esempio n. 30
0
 public int Add(Model.Setting setting)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         dataEntities.AddToSettings(setting);
         return dataEntities.SaveChanges();
     }
 }