示例#1
0
 public Model.Profile Single(int profileID)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Profiles.Single(pro => pro.ProfileID == profileID);
     }
 }
示例#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();
     }
 }
示例#3
0
 public List<Model.Profile> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Profiles.Where(p => p.Active == true).ToList();
     }
 }
示例#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();
     }
 }
 public List<WebPortal.Model.ChucVu_GiaoVien> chucvu(int idGiaoVien)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.ChucVu_GiaoVien.Where(app => app.IDGiaoVien == idGiaoVien).ToList();
     }
 }
示例#6
0
 public List<Model.InRole> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.InRoles.ToList();
     }
 }
示例#7
0
 public Model.Setting Single(int settingID)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Settings.Single(setting => setting.SettingID == settingID);
     }
 }
示例#8
0
 public WebPortal.Model.ToChuc Single(int idToChuc)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.ToChucs.Single(app => app.IDToChuc == idToChuc);
     }
 }
 public List<WebPortal.Model.ToChuc_GiaoVien> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.ToChuc_GiaoVien.ToList();
     }
 }
示例#10
0
 public List<Model.User> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Users.Where(user => user.Active == true).ToList();
     }
 }
示例#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();
     }
 }
示例#12
0
 public List<Model.Group> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Groups.Where(gr => gr.Active == true).ToList();
     }
 }
示例#13
0
 public List<Model.Setting> Paging(int start, int numberRecords)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Settings.Skip(start).Take(numberRecords).ToList();
     }
 }
示例#14
0
 public List<Model.Permission> Get_All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Permissions.ToList();
     }
 }
示例#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();
     }
 }
示例#16
0
 public List<Model.Permission> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Permissions.Where(per=>per.Active==true).ToList();
     }
 }
示例#17
0
 public WebPortal.Model.TaiNguyen Single(int idTaiNguyen)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.TaiNguyens.Single(app => app.IDTaiNguyen == idTaiNguyen);
     }
 }
示例#18
0
 public List<WebPortal.Model.TinTuc> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.TinTucs.ToList();
     }
 }
示例#19
0
 public List<WebPortal.Model.TaiNguyen> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.TaiNguyens.ToList();
     }
 }
示例#20
0
 public List<WebPortal.Model.LoaiTin_Lv1> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.LoaiTin_Lv1.ToList();
     }
 }
示例#21
0
 public List<Model.Group> Get_All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Groups.ToList();
     }
 }
示例#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();
     }
 }
示例#23
0
 public List<Model.Setting> All()
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         return dataEntities.Settings.ToList();
     }
 }
示例#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();
     }
 }
示例#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();
                    }
                }
            }
        }
示例#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();
                    }
                }
            }
        }
示例#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();
                    }
                }
            }
        }
示例#28
0
 public int Delete(Model.Setting setting)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         dataEntities.DeleteObject(setting);
         return dataEntities.SaveChanges();
     }
 }
示例#29
0
 public int Delete(Model.Permission permission)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         dataEntities.DeleteObject(permission);
         return dataEntities.SaveChanges();
     }
 }
示例#30
0
 public int Add(Model.Setting setting)
 {
     using (WebPortalEntities dataEntities = new WebPortalEntities())
     {
         dataEntities.AddToSettings(setting);
         return dataEntities.SaveChanges();
     }
 }