public ActionResult SearchQuestionGroupList(QuestionGroupSearchFilter searchFilter) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Search QuestionGroup").ToInputLogString()); try { if (ModelState.IsValid) { _questionGroupFacade = new QuestionGroupFacade(); QuestionGroupViewModel questionGroupVM = new QuestionGroupViewModel(); questionGroupVM.SearchFilter = searchFilter; questionGroupVM.QuestionGroupList = _questionGroupFacade.GetQuestionGroupList(questionGroupVM.SearchFilter); ViewBag.PageSize = questionGroupVM.SearchFilter.PageSize; return(PartialView("~/Views/QuestionGroup/_QuestionGroupList.cshtml", questionGroupVM)); } return(Json(new { Valid = false, Error = string.Empty })); } catch (Exception ex) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Search QuestionGroup").ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public IEnumerable <QuestionGroupItemEntity> GetQuestionGroupList(QuestionGroupSearchFilter searchFilter) { var questionGroupListStatus = searchFilter.Status.ToNullable <bool>(); var resultQuery = (from questionGroup in _context.TB_M_QUESTIONGROUP from createUser in _context.TB_R_USER.Where(x => x.USER_ID == questionGroup.CREATE_USER).DefaultIfEmpty() from updateUser in _context.TB_R_USER.Where(x => x.USER_ID == questionGroup.UPDATE_USER).DefaultIfEmpty() where ((searchFilter.QuestionGroupName == null || questionGroup.QUESTIONGROUP_NAME.Contains(searchFilter.QuestionGroupName)) && (!searchFilter.ProductId.HasValue || questionGroup.PRODUCT_ID == searchFilter.ProductId) && (!questionGroupListStatus.HasValue || questionGroup.QUESTIONGROUP_IS_ACTIVE == questionGroupListStatus)) select new QuestionGroupItemEntity { QuestionGroupId = questionGroup.QUESTIONGROUP_ID, QuestionGroupName = questionGroup.QUESTIONGROUP_NAME, QuestionNo = questionGroup.TB_M_QUESTIONGROUP_QUESTION.Count(), ProductName = questionGroup.TB_R_PRODUCT.PRODUCT_NAME, Status = questionGroup.QUESTIONGROUP_IS_ACTIVE, UpdateUserName = (updateUser != null ? new UserEntity() { PositionCode = updateUser.POSITION_CODE, Firstname = updateUser.FIRST_NAME, Lastname = updateUser.LAST_NAME } : null), UpdateDate = questionGroup.UPDATE_DATE }); resultQuery = resultQuery.OrderBy(r => r.QuestionGroupName); int startPageIndex = (searchFilter.PageNo - 1) * searchFilter.PageSize; searchFilter.TotalRecords = resultQuery.Count(); if (startPageIndex >= searchFilter.TotalRecords) { startPageIndex = 0; searchFilter.PageNo = 1; } // resultQuery = SetQuestionGroupListSort(resultQuery, searchFilter); return(resultQuery.Skip(startPageIndex).Take(searchFilter.PageSize).ToList()); }
public IEnumerable <QuestionGroupItemEntity> GetQuestionGroupList(QuestionGroupSearchFilter searchFilter) { _questionGroupDataAccess = new QuestionGroupDataAccess(_context); return(_questionGroupDataAccess.GetQuestionGroupList(searchFilter)); }