public QueryResult <PlanningApp> GetPlanningAppsSearchCriteria(PlanningAppQuery queryObj) { var result = new QueryResult <PlanningApp>(); var resList = new List <PlanningApp>(); //Provide sorting list for columns if required var columnsMap = new Dictionary <string, Expression <Func <PlanningApp, object> > >() { ["planningReferenceId"] = r => r.PlanningReferenceId, ["descriptionOfWork"] = v => v.DescriptionOfWork, }; var query = vegaDbContext.PlanningApps .Include(b => b.CurrentPlanningStatus) .Include(t => t.PlanningAppStates) .ThenInclude(a => a.StateStatus) .Include(t => t.PlanningAppStates) .ThenInclude(s => s.state) .Include(c => c.Customer.CustomerContact) .AsQueryable(); if (queryObj.PlanningReferenceId != null) { query = query.Where(r => r.PlanningReferenceId.Contains(queryObj.PlanningReferenceId)); } query = query.ApplyOrdering(queryObj, columnsMap); result.TotalItems = query.Count(); query = query.ApplyPaging(queryObj); result.Items = query.ToList(); return(result); }
public QueryResult <PlanningApp> GetPlanningApps(PlanningAppQuery queryObj) { var result = new QueryResult <PlanningApp>(); var resList = new List <PlanningApp>(); var query = vegaDbContext.PlanningApps .Include(b => b.CurrentPlanningStatus) .Include(t => t.PlanningAppStates) .ThenInclude(a => a.StateStatus) .Include(t => t.PlanningAppStates) .ThenInclude(s => s.state) .Include(c => c.Customer.CustomerContact) .AsQueryable(); if (queryObj.CustomerId > 0) { query = query.Where(c => c.Customer.Id == queryObj.CustomerId); } if (queryObj.PlanningAppType == null) { queryObj.PlanningAppType = StatusList.AppInProgress; } //Build up list of planning apps List <PlanningApp> planningAppSelectList = new List <PlanningApp>(); if (queryObj.PlanningAppType == StatusList.All) { planningAppSelectList = getAppsInProgress(query); planningAppSelectList.AddRange(getAppsNotInProgress(query)); } else if (queryObj.PlanningAppType == StatusList.AppInProgress) { planningAppSelectList = getAppsInProgress(query); } else if (queryObj.PlanningAppType == StatusList.AppNotInProgress) //ie, Completed/Archived/Terminated { planningAppSelectList = getAppsNotInProgress(query); } else { planningAppSelectList = getAppsWithStatus(query, queryObj.PlanningAppType); //Individual state selected } query = planningAppSelectList.AsQueryable(); result.TotalItems = query.Count(); query = query.ApplyPaging(queryObj); result.Items = query.ToList(); return(result); }
public PlanningStatistics getPlanningStatistics() { var planingStatistics = new PlanningStatistics(); PlanningAppQuery planningAppQuery = new PlanningAppQuery(); QueryResult <PlanningApp> result = new QueryResult <PlanningApp>(); planningAppQuery.PlanningAppType = StatusList.AppInProgress; result = PlanningAppRepository.GetPlanningApps(planningAppQuery); planingStatistics.InProgress = result.TotalItems; planningAppQuery.PlanningAppType = StatusList.OnTime; result = PlanningAppRepository.GetPlanningApps(planningAppQuery); planingStatistics.OnTime = result.TotalItems; planningAppQuery.PlanningAppType = StatusList.Due; result = PlanningAppRepository.GetPlanningApps(planningAppQuery); planingStatistics.Due = result.TotalItems; planningAppQuery.PlanningAppType = StatusList.Overdue; result = PlanningAppRepository.GetPlanningApps(planningAppQuery); planingStatistics.Overdue = result.TotalItems; planningAppQuery.PlanningAppType = StatusList.All; result = PlanningAppRepository.GetPlanningApps(planningAppQuery); planingStatistics.All = result.TotalItems; planningAppQuery.PlanningAppType = StatusList.AppTerminated; result = PlanningAppRepository.GetPlanningApps(planningAppQuery); planingStatistics.Terminated = result.TotalItems; planningAppQuery.PlanningAppType = StatusList.Complete; result = PlanningAppRepository.GetPlanningApps(planningAppQuery); planingStatistics.Completed = result.TotalItems; return(planingStatistics); }