public async Task <ApiResult <object> > GetProjectViewModel() { var res = new ApiResult <object>() { statusCode = (int)ApiEnum.Status }; FilterDefinition <ProjectInfo> filter = Builders <ProjectInfo> .Filter.Empty; var list = Projectdb.GetList("Projects", filter); List <BaseViewModel1> advertlist = new List <BaseViewModel1>(); foreach (var item in list) { advertlist.Add(new BaseViewModel1(C.String(item._id), item.Names)); } res.data = advertlist; return(await Task.Run(() => res)); }
public async Task <ApiResult <IEnumerable <ProjectNodeViewModel> > > GetList(int pageIndex, string?ProjectTypeID, string?ProjectID, bool?IsEnable, int?State, string?Title) { var res = new ApiResult <IEnumerable <ProjectNodeViewModel> >() { statusCode = (int)ApiEnum.Status }; int UserID = GetUserID(); if (UserID > 0) { if (pageIndex == 0) { pageIndex = 1; } var parm = Expressionable.Create <ProjectNodeInfo>(); PagedInfo <ProjectNodeInfo> list = null; UserInfo userInfo = userdb.GetId(UserID); if (userInfo != null) { var parm2 = Expressionable.Create <ProjectUserInfo>() .AndIF(userInfo.RoleID != 1, o => o.UserID == UserID) .And(o => o.IsEnable == true); List <ProjectUserInfo> projectUserInfo = projectUserdb.GetWhere(parm2.ToExpression()); int[] nodes; if (projectUserInfo != null && projectUserInfo.Count > 0) { if (userInfo.RoleID != 1) { nodes = new int[projectUserInfo.Count]; int i = 0; foreach (var item in projectUserInfo) { nodes[i] = item.ProjectNodeID; i++; } parm.AndIF(nodes.Length > 0, o => nodes.Contains(o.ID)); } parm.AndIF(!string.IsNullOrWhiteSpace(ProjectID), m => m.ProjectID == ProjectID); parm.AndIF(IsEnable != null, m => m.IsEnable == IsEnable); parm.AndIF(State != null, m => m.State == State); parm.AndIF(!string.IsNullOrWhiteSpace(Title), m => m.Title.Contains(Title)); parm.And(m => m.TypeID == 1); if (!string.IsNullOrWhiteSpace(ProjectTypeID)) { List <ProjectInfo> projects = Projectdb.GetList("Projects", Builders <ProjectInfo> .Filter.Where(o => o.ProjectTypeID == ProjectTypeID), null, null); string[] x = new string[projects.Count]; int a = 0; foreach (var item in projects) { x[a] = item.ID; a++; } parm.And(m => x.Contains(m.ProjectID)); } list = PNdb.GetPages(parm.ToExpression(), new PageParm(pageIndex), "ID DESC"); } List <ProjectNodeViewModel> list2 = new List <ProjectNodeViewModel>(); if (list != null) { foreach (var item in list.DataSource) { ProjectNodeViewModel projectNodeViewModel = IMapper.Map <ProjectNodeViewModel>(item); projectNodeViewModel.PlanCount = plandb.GetCount(o => o.ProjectNodeID == item.ID && o.ProjectID == item.ProjectID); ProjectInfo projectInfo = Projectdb.Get("Projects", item.ProjectID); List <UserInfo> userInfos = userdb.GetWhere(a => SqlFunc.Subqueryable <ProjectUserInfo>().Where(b => b.UserID == a.ID && b.ProjectNodeID == item.ID && b.Role == 1 && b.IsEnable == true).Any()); if (userInfos != null) { List <APITeamMembersViewModel> ats = new List <APITeamMembersViewModel>(); foreach (var item2 in userInfos) { ats.Add(new APITeamMembersViewModel() { ID = item2.ID, Name = userdb.GetNames(item2) }); } projectNodeViewModel.Teamleades = ats; } List <UserInfo> userInfos2 = userdb.GetWhere(a => SqlFunc.Subqueryable <ProjectUserInfo>().Where(b => b.UserID == a.ID && b.ProjectNodeID == item.ID && b.Role == 2 && b.IsEnable == true).Any()); if (userInfos2 != null) { List <APITeamMembersViewModel> ats = new List <APITeamMembersViewModel>(); foreach (var item2 in userInfos2) { ats.Add(new APITeamMembersViewModel() { ID = item2.ID, Name = userdb.GetNames(item2) }); } projectNodeViewModel.Teammembers = ats; } if (projectInfo != null) { projectNodeViewModel.ProjectName = projectInfo.Names; projectNodeViewModel.ProjectTypeID = projectInfo.ProjectTypeID; } list2.Add(projectNodeViewModel); } res.success = true; res.data = list2; res.index = pageIndex; res.count = list.TotalCount; res.size = list.PageSize; res.pages = list.TotalPages; } else { res.success = true; res.statusCode = (int)ApiEnum.Status; } } else { res.msg = "无该用户信息"; } } else { res.msg = "请重新登陆"; } return(await Task.Run(() => res)); }
public ResponseResult <List <ProjectInfoEditDto> > GetList() { var res = _projectInfoService.GetList(); return(res.Clone <List <ProjectInfoEditDto> >().Success()); }