public IActionResult TestCustomer(TestSearchCriteriaViewModel searchCriteria, TestDashboard currentDashboard) { var userId = _contextAccessor.HttpContext.User.Identity.GetUserId(); // مراحل تازههای کارتابل فعلی چیست searchCriteria.RoutineStepList = _routine2Repository.GetRoleSteps(TestRoutine.RoutineId, currentDashboard.ToString()); // کاربر در سمت فعلی، بر روی چه طرحهایی عملیاتی انجام داده است searchCriteria.RoutineLogList = _routine2Repository.GetUserEntityIds(TestRoutine.RoutineId, Convert.ToInt32(userId), currentDashboard.ToString()); #region DashboardType: Draft, New, Archived, Done // پیش نویسها if (searchCriteria.DashboardType == DashboardTypes.Draft) { searchCriteria.RoutineIsFlown = false; } if (searchCriteria.DashboardType == DashboardTypes.Done) { searchCriteria.RoutineIsDone = true; } #endregion var data = _testService.GetData(searchCriteria); var model = new Routine2PageModel <List <TestSummeryDTO>, TestSearchCriteriaViewModel, TestDashboard>(data, searchCriteria, currentDashboard); return(View(model)); }
public List <TestSummeryDTO> GetData(TestSearchCriteriaViewModel searchCriteria, int currPage = 1, int pageSize = 10) { var model = _context.Test.AsNoTracking(); model = model.Where(q => q.RoutineIsFlown == searchCriteria.RoutineIsFlown); model = model.WhereIf(searchCriteria.RoutineIsDone.HasValue, q => q.RoutineIsDone == searchCriteria.RoutineIsDone); // تازهها model = model.WhereIf(searchCriteria.DashboardType == DashboardTypes.New, q => searchCriteria.RoutineStepList.Contains(q.RoutineStep)); // ارسال شده ها model = model.WhereIf(searchCriteria.DashboardType == DashboardTypes.Archived, q => searchCriteria.RoutineLogList.Contains(q.Id) && !searchCriteria.RoutineStepList.Contains(q.RoutineStep)); // خاتمه یافته ها model = model.WhereIf(searchCriteria.DashboardType == DashboardTypes.Done, q => searchCriteria.RoutineLogList.Contains(q.Id) && TestRoutine.DoneSteps.Contains(q.RoutineStep)); //model = model.WhereIf(searchCriteria.DashboardType == DashboardTypes.Draft, // q => q.UserId == searchCriteria.UserId); model = model.WhereIf(searchCriteria.Step.HasValue, q => q.RoutineStep == searchCriteria.Step.Value); model = searchCriteria.DashboardType == DashboardTypes.New ? model.OrderBy(q => q.RoutineStepChangeDate) : model.OrderByDescending(q => q.RoutineStepChangeDate); return(model.ProjectTo <TestSummeryDTO>().ToList()); }