public void Delete() { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { dal.GetRepository <Test>().Get().Delete(); dal.Save(); } }
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>()); } }
public List <Role> GetRoleItem() { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { return(dal.GetRepository <Role>().Get(orderBy: a => a.OrderByDescending(q => q.RoleID)).ToList()); } }
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)); } }
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)); } }
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); } }
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()); } }
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)); } }
public SystemInfo GetSystemInfo() { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { return(dal.GetRepository <SystemInfo>().Get().FirstOrDefault()); } }
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); } } }
public List <Button> GetButtonList() { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { return(dal.GetRepository <Button>().Get().ToList()); } }
public List <RoleMappingButton> GetbtnAuthByRole(int roleID) { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { return(dal.GetRepository <RoleMappingButton>().Get(a => a.RoleID == roleID).ToList()); } }
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()); } }
/// <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(); } }
public void ModifyMenu(Menu model) { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { dal.GetRepository <Menu>().Update(model); dal.Save(); } }
public void DeleteBtn(int btnID) { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { dal.GetRepository <Button>().Delete(btnID); dal.Save(); } }
public void AddLoginlog(LoginLog model) { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { dal.GetRepository <LoginLog>().Insert(model); dal.Save(); } }
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); } }
public void AddRB(List <RoleMappingButton> modelList) { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { dal.GetRepository <RoleMappingButton>().Insert(modelList); dal.Save(); } }
public void DeleteMenu(int Menuid) { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { dal.GetRepository <Menu>().Delete(Menuid); dal.Save(); } }
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(); } }
public void AddMenu(Menu model) { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { dal.GetRepository <Menu>().Insert(model); dal.Save(); } }
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(); } }
public void ModifyBtn(Button model) { using (UnitOfWork dal = new UnitOfWork(ConnectDB.DataBase())) { dal.GetRepository <Button>().UpdateSup(model, new List <string>() { "CreateTime" }, false); dal.Save(); } }
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(); } }
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()); } }