public ActionResult SearchQuestionGroupMapList(QuestionSelectSearchFilter searchFilter)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Mapping").ToInputLogString());

            try
            {
                if (ModelState.IsValid)
                {
                    _mappingProductTypeFacade = new MappingProductTypeFacade();
                    MappingProductTypeViewModel model = new MappingProductTypeViewModel();
                    model.QuestionGroupSearchFilter = searchFilter;

                    model.QuestionGroupList =
                        _mappingProductTypeFacade.GetQuestionGroupList(model.QuestionGroupSearchFilter);
                    ViewBag.PageSize = model.QuestionGroupSearchFilter.PageSize;

                    return(PartialView("~/Views/MappingProductType/_QuestionGroupList.cshtml", model));
                }

                return(Json(new
                {
                    Valid = false,
                    Error = string.Empty
                }));
            }
            catch (Exception ex)
            {
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Mapping").ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Beispiel #2
0
        public ActionResult SearchQuestionList(QuestionSelectSearchFilter searchFilter)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Question").ToInputLogString());

            try
            {
                if (ModelState.IsValid)
                {
                    _questionGroupFacade = new QuestionGroupFacade();
                    var model = new QuestionGroupEditViewModel();
                    model.SearchFilter = searchFilter;
                    model.QuestionList = _questionGroupFacade.GetQuestionList(model.SearchFilter);
                    ViewBag.PageSize   = model.SearchFilter.PageSize;
                    return(PartialView("~/Views/QuestionGroup/_QuestionList.cshtml", model));
                }

                return(Json(new
                {
                    Valid = false,
                    Error = string.Empty
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Question").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Beispiel #3
0
        public IEnumerable <QuestionGroupTableItemEntity> GetQuestionGroupList(QuestionSelectSearchFilter searchFilter)
        {
            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.QuestionName == null || questionGroup.QUESTIONGROUP_NAME.Contains(searchFilter.QuestionName)) &&
                                (searchFilter.ProductId == null || questionGroup.PRODUCT_ID == searchFilter.ProductId))
                               select new QuestionGroupTableItemEntity
            {
                QuestionGroupId = questionGroup.QUESTIONGROUP_ID,
                QuestionGroupName = questionGroup.QUESTIONGROUP_NAME,
                IsActive = questionGroup.QUESTIONGROUP_IS_ACTIVE,
                UpdateUser = (updateUser != null
                        ? new UserEntity()
                {
                    PositionCode = updateUser.POSITION_CODE,
                    Firstname = updateUser.FIRST_NAME,
                    Lastname = updateUser.LAST_NAME
                }
                        : null),
                CreateUser = (createUser != null
                        ? new UserEntity()
                {
                    PositionCode = createUser.POSITION_CODE,
                    Firstname = createUser.FIRST_NAME,
                    Lastname = createUser.LAST_NAME
                }
                        : null),
                UpdateDate = questionGroup.UPDATE_DATE,
                ProductId = questionGroup.PRODUCT_ID,
                Description = questionGroup.QUESTIONGROUP_DESC,
                QuestionNo = questionGroup.TB_M_QUESTIONGROUP_QUESTION.Count()
            });

            if (!string.IsNullOrEmpty(searchFilter.QuestionIdList))
            {
                var questionIdArray = searchFilter.QuestionIdList.Split(',').Select(s => Convert.ToInt32(s)).ToList();
                resultQuery = resultQuery.Where(q => !questionIdArray.Contains(q.QuestionGroupId));
            }

            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());
        }
Beispiel #4
0
        public List <QuestionItemEntity> GetQuestionList(QuestionSelectSearchFilter searchFilter)
        {
            var resultQuery = (from question in _context.TB_M_QUESTION
                               from createUser in _context.TB_R_USER.Where(x => x.USER_ID == question.CREATE_USER).DefaultIfEmpty()
                               from updateUser in _context.TB_R_USER.Where(x => x.USER_ID == question.UPDATE_USER).DefaultIfEmpty()
                               where (searchFilter.QuestionName == null || question.QUESTION_NAME.Contains(searchFilter.QuestionName))
                               select new QuestionItemEntity
            {
                QuestionId = question.QUESTION_ID,
                QuestionName = question.QUESTION_NAME,
                IsActive = question.IS_ACTIVE != null && (bool)question.IS_ACTIVE ? "Active" : "Inactive",
                UpdateUserName = (updateUser != null ? new UserEntity()
                {
                    PositionCode = updateUser.POSITION_CODE,
                    Firstname = updateUser.FIRST_NAME,
                    Lastname = updateUser.LAST_NAME
                } : null),
                CreateUserName = (createUser != null ? new UserEntity()
                {
                    PositionCode = createUser.POSITION_CODE,
                    Firstname = createUser.FIRST_NAME,
                    Lastname = createUser.LAST_NAME
                } : null),
                UpdateDate = question.UPDATE_DATE.HasValue ? question.UPDATE_DATE : question.CREATE_DATE,
                CreateUser = (int)question.CREATE_USER,
                UpdateUser = (int)question.UPDATE_USER
            });

            if (!string.IsNullOrEmpty(searchFilter.QuestionIdList))
            {
                var questionIdArray = searchFilter.QuestionIdList.Split(',').Select(s => Convert.ToInt32(s)).ToList();
                resultQuery = resultQuery.Where(q => !questionIdArray.Contains(q.QuestionId.Value));
            }

            int startPageIndex = (searchFilter.PageNo - 1) * searchFilter.PageSize;

            searchFilter.TotalRecords = resultQuery.Count();

            if (startPageIndex >= searchFilter.TotalRecords)
            {
                startPageIndex      = 0;
                searchFilter.PageNo = 1;
            }

            resultQuery = SetQuestionListSort(resultQuery, searchFilter);

            return(resultQuery.Skip(startPageIndex).Take(searchFilter.PageSize).ToList());
        }
Beispiel #5
0
 private static IQueryable <QuestionItemEntity> SetQuestionListSort(IQueryable <QuestionItemEntity> areaList, QuestionSelectSearchFilter searchFilter)
 {
     if (searchFilter.SortOrder.ToUpper(CultureInfo.InvariantCulture).Equals("ASC"))
     {
         switch (searchFilter.SortField.ToUpper(CultureInfo.InvariantCulture))
         {
         default:
             return(areaList.OrderBy(a => a.QuestionName));
         }
     }
     else
     {
         switch (searchFilter.SortField.ToUpper(CultureInfo.InvariantCulture))
         {
         default:
             return(areaList.OrderByDescending(a => a.QuestionName));
         }
     }
 }
 public IEnumerable <QuestionGroupTableItemEntity> GetQuestionGroupList(QuestionSelectSearchFilter searchFilter)
 {
     _mappingProductTypeDataAccess = new MappingProductTypeDataAccess(_context);
     return(_mappingProductTypeDataAccess.GetQuestionGroupList(searchFilter));
 }
Beispiel #7
0
 public List <QuestionItemEntity> GetQuestionList(QuestionSelectSearchFilter searchFilter)
 {
     _questionGroupDataAccess = new QuestionGroupDataAccess(_context);
     return(_questionGroupDataAccess.GetQuestionList(searchFilter));
 }