コード例 #1
0
 public void Delete()
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) {
         dal.GetRepository <Test>().Get().Delete();
         dal.Save();
     }
 }
コード例 #2
0
 public Test GetSingle(int ID)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         return(dal.GetRepository <Test>().Get(a => a.ID == ID, includeProperties: "Account").FirstOrDefault <Test>());
     }
 }
コード例 #3
0
 public List <Role> GetRoleItem()
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         return(dal.GetRepository <Role>().Get(orderBy: a => a.OrderByDescending(q => q.RoleID)).ToList());
     }
 }
コード例 #4
0
        public Tuple <int, List <LoginLog> > GetLoginlog(LoginLog model)
        {
            using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
            {
                var loginRepository = dal.GetRepository <LoginLog>();
                var conditions      = ExpandHelper.True <LoginLog>();
                if (!string.IsNullOrEmpty(model.LoginName))
                {
                    conditions = conditions.And(a => a.LoginName.Contains(model.LoginName));
                }

                if (!string.IsNullOrEmpty(model.LoginNicker))
                {
                    conditions = conditions.And(a => a.LoginNicker.Contains(model.LoginNicker));
                }

                var logmodel = loginRepository.Get(filter: conditions);

                var count = logmodel.Count();

                if (model.order != null && model.order.Count() > 0)
                {
                    foreach (var item in model.order)
                    {
                        var column = model.columns.ElementAt(int.Parse(item.column));
                        logmodel = logmodel.OrderSort(column.data, item.dir);
                    }
                }

                var result = logmodel.PageBy(model.pageIndex, model.pageSize).ToList();

                return(new Tuple <int, List <LoginLog> >(count, result));
            }
        }
コード例 #5
0
        public Tuple <int, List <Role> > GetRoleList(Role model)
        {
            using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
            {
                var conditions = ExpandHelper.True <Role>();
                if (!string.IsNullOrEmpty(model.RoleName))
                {
                    conditions = conditions.And(a => a.RoleName.Contains(model.RoleName));
                }
                var templist = dal.GetRepository <Role>().Get(filter: conditions, includeProperties: "MenuList.mbList");

                var count = templist.Count();

                if (model.order != null && model.order.Count() > 0)
                {
                    foreach (var item in model.order)
                    {
                        var column = model.columns.ElementAt(int.Parse(item.column));
                        templist = templist.OrderSort(column.data, item.dir);
                    }
                }

                var result = templist.PageBy(model.pageIndex, model.pageSize).ToList();

                return(new Tuple <int, List <Role> >(count, result));
            }
        }
コード例 #6
0
 public User GetSingle(User model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())){
         var result = dal.GetRepository <User>().Get(filter: a => a.UserName == model.UserName, includeProperties: "RoleList").FirstOrDefault();
         return(result);
     }
 }
コード例 #7
0
 public Menu GetSingleMenu(int Menuid)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         return(dal.GetRepository <Menu>().Get(filter: a => a.MenuID == Menuid, includeProperties: "mbList").FirstOrDefault());
     }
 }
コード例 #8
0
        public Tuple <int, List <News> > GetNewsList(News model)
        {
            using (var dal = new UnitOfWork(ConnectDB.DataBase())){
                var newsRepository = dal.GetRepository <News>();
                var conditions     = ExpandHelper.True <News>();
                if (!string.IsNullOrEmpty(model.NewTitle))
                {
                    conditions = conditions.And(a => a.NewTitle.Contains(model.NewTitle));
                }

                var templist = newsRepository.Get(filter: conditions);

                var count = templist.Count();

                if (model.order != null && model.order.Count() > 0)
                {
                    foreach (var item in model.order)
                    {
                        var column = model.columns.ElementAt(int.Parse(item.column));
                        templist = templist.OrderSort(column.data, item.dir);
                    }
                }

                var result = templist.PageBy(model.pageIndex, model.pageSize).ToList();

                return(new Tuple <int, List <News> >(count, result));
            }
        }
コード例 #9
0
 public SystemInfo GetSystemInfo()
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         return(dal.GetRepository <SystemInfo>().Get().FirstOrDefault());
     }
 }
コード例 #10
0
 public Menu OrderAssignment(Menu model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         var menuRepository = dal.GetRepository <Menu>();
         model.CreateTime = DateTime.Now;
         if (model.MenuOrder == 0)
         {
             Menu maxModel = new Menu();
             if (model.MenuParentID == null)
             {
                 maxModel = menuRepository.Get(filter: a => a.MenuParentID.Equals(model.MenuParentID), orderBy: p => p.OrderByDescending(s => s.MenuOrder)).FirstOrDefault();
             }
             else
             {
                 maxModel = menuRepository.Get(filter: a => a.MenuParentID == model.MenuParentID, orderBy: p => p.OrderByDescending(s => s.MenuOrder)).FirstOrDefault();
             }
             model.MenuOrder = maxModel != null?maxModel.MenuOrder + 1:1;
             return(model);
         }
         else
         {
             return(model);
         }
     }
 }
コード例 #11
0
 public List <Button> GetButtonList()
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         return(dal.GetRepository <Button>().Get().ToList());
     }
 }
コード例 #12
0
 public List <RoleMappingButton> GetbtnAuthByRole(int roleID)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         return(dal.GetRepository <RoleMappingButton>().Get(a => a.RoleID == roleID).ToList());
     }
 }
コード例 #13
0
 public Button GetSingleBtnbyID(int id)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         return(dal.GetRepository <Button>().GetByID(id));
     }
 }
 public List <DictionaryCategory> DiCategoryList()
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         return(dal.GetRepository <DictionaryCategory>().Get(filter: a => a.Enabled == true, includeProperties: "DicValueList").ToList());
     }
 }
コード例 #15
0
        /// <summary>
        /// 添加用户角色信息,先删除原有数据,在添加到数据库
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="roleIDList"></param>
        /// <returns></returns>
        public void SetUserInfoRole(int userID, List <int> roleIDList)
        {
            using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
            {
                var sysUserRepository = dal.GetRepository <User>();
                var roleRepository    = dal.GetRepository <Role>();
                var UserModel         = GetbyID(userID);
                var roleList          = UserModel.RoleList.ToList();

                roleList.ForEach(m =>
                {
                    var userModel = sysUserRepository.Get(filter: a => a.UserID == userID, includeProperties: "RoleList").FirstOrDefault();
                    var roleModel = roleRepository.GetByID(m.RoleID);
                    userModel.RoleList.Remove(roleModel);
                });

                roleIDList.ForEach(m =>
                {
                    var userModel = sysUserRepository.GetByID(userID);
                    var roleModel = roleRepository.GetByID(m);
                    userModel.RoleList.Add(roleModel);
                });

                dal.Save();
            }
        }
コード例 #16
0
 public void ModifyMenu(Menu model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         dal.GetRepository <Menu>().Update(model);
         dal.Save();
     }
 }
コード例 #17
0
 public void DeleteBtn(int btnID)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         dal.GetRepository <Button>().Delete(btnID);
         dal.Save();
     }
 }
コード例 #18
0
 public void AddLoginlog(LoginLog model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         dal.GetRepository <LoginLog>().Insert(model);
         dal.Save();
     }
 }
コード例 #19
0
 public List <MenuMappingButton> GetMBList(MenuMappingButton model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         var listMb = dal.GetRepository <MenuMappingButton>().Get(filter: a => a.ButtonID == model.ButtonID).ToList();
         return(listMb);
     }
 }
コード例 #20
0
 public void AddRB(List <RoleMappingButton> modelList)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         dal.GetRepository <RoleMappingButton>().Insert(modelList);
         dal.Save();
     }
 }
コード例 #21
0
 public void DeleteMenu(int Menuid)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         dal.GetRepository <Menu>().Delete(Menuid);
         dal.Save();
     }
 }
コード例 #22
0
 public void AddBtn(Button model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         dal.GetRepository <Button>().Insert(model);
         dal.Save();
     }
 }
 public void AddDic(DictionaryCategory model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         dal.GetRepository <DictionaryCategory>().Insert(model);
         dal.Save();
     }
 }
コード例 #24
0
 public void AddMenu(Menu model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         dal.GetRepository <Menu>().Insert(model);
         dal.Save();
     }
 }
コード例 #25
0
 public List <Menu> GetParentMenu()
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         var result = dal.GetRepository <Menu>().Get(filter: p => p.MenuParentID == null, includeProperties: "Childs,Childs.mbList.ButtonModel").ToList();
         return(result);
     }
 }
 public void ModifyDic(DictionaryCategory model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         dal.GetRepository <DictionaryCategory>().UpdateSup(model, new List <string>()
         {
             "CreateTime", "Enabled"
         }, false);
         dal.Save();
     }
 }
 public void DisabledDic(int btnID)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         var dictionaryCategoryRepository = dal.GetRepository <DictionaryCategory>();
         var entity = dictionaryCategoryRepository.GetByID(btnID);
         entity.Enabled = false;
         dictionaryCategoryRepository.Update(entity);
         dal.Save();
     }
 }
コード例 #28
0
 public void ModifyBtn(Button model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         dal.GetRepository <Button>().UpdateSup(model, new List <string>()
         {
             "CreateTime"
         }, false);
         dal.Save();
     }
 }
コード例 #29
0
 public void ModifyUser(User model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         dal.GetRepository <User>().UpdateSup(model, new List <string>()
         {
             "IsEnable", "CreateTime"
         }, false);
         dal.Save();
     }
 }
コード例 #30
0
 public Role Validate(Role model)
 {
     using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase()))
     {
         var temp = dal.GetRepository <Role>().Get(filter: a => a.RoleName == model.RoleName);
         if (model.RoleID != 0)
         {
             temp = temp.Where(a => a.RoleID == model.RoleID);
         }
         return(temp.FirstOrDefault());
     }
 }