public ActionResult ViewQuestionGroup(int id)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("View Question Group").Add("QuestionGroupId", id).ToSuccessLogString());

            try
            {
                _questionGroupFacade = new QuestionGroupFacade();
                var questionGroup = _questionGroupFacade.GetQuestionGroupById(id);
                var questionList  = _questionGroupFacade.GetQuestionList(id);

                var model = new ViewQuestionGroupModel();
                model.Name        = questionGroup.QuestionGroupName;
                model.Description = questionGroup.Description;
                model.ProductName = questionGroup.ProductName;
                model.Status      = (questionGroup.Status ?? false) ? "Active" : "Inactive";
                model.CreateUser  = questionGroup.CreateUserName;
                model.UpdateUser  = questionGroup.UpdateUserName;
                model.CreateDate  = DateUtil.ToStringAsDateTime(questionGroup.CreateDate);
                model.UpdateDate  = DateUtil.ToStringAsDateTime(questionGroup.UpdateDate);

                model.QuestionList = questionList.Select(x => new ViewQuestionModel()
                {
                    SeqNo        = x.SeqNo,
                    QuestionName = x.QuestionName,
                }).ToList();

                return(View(model));
            }
            catch (Exception ex)
            {
                Logger.Info(_logMsg.Clear().SetPrefixMsg("View Question Group").ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Exemple #2
0
        public ActionResult Edit(int?questionGroupId)
        {
            if (questionGroupId.HasValue)
            {
                var questionGroupVM = new QuestionGroupEditViewModel();
                _questionGroupFacade = new QuestionGroupFacade();

                //get area section
                QuestionGroupItemEntity questionGroupItemEntity = _questionGroupFacade.GetQuestionGroupById(questionGroupId.Value);
                questionGroupVM.QuestionGroupId          = questionGroupItemEntity.QuestionGroupId;
                questionGroupVM.QuestionGroupName        = questionGroupItemEntity.QuestionGroupName;
                questionGroupVM.QuestionGroupProductName = questionGroupItemEntity.QuestionGroupProduct;
                questionGroupVM.QuestionGroupProductId   = questionGroupItemEntity.QuestionGroupProductId;
                questionGroupVM.CreateUserName           = questionGroupItemEntity.CreateUserName != null ? questionGroupItemEntity.CreateUserName.FullName : "";
                questionGroupVM.UpdateUserName           = questionGroupItemEntity.UpdateUserName != null ? questionGroupItemEntity.UpdateUserName.FullName : "";
                questionGroupVM.DisplayCreateDate        = DateUtil.ToStringAsDateTime(questionGroupItemEntity.CreateDate);
                questionGroupVM.DisplayUpdateDate        = DateUtil.ToStringAsDateTime(questionGroupItemEntity.UpdateDate);
                questionGroupVM.QuestionGroupDescription = questionGroupItemEntity.Description;

                questionGroupVM.Status     = questionGroupItemEntity.Status;
                questionGroupVM.StatusList = new List <SelectListItem>();

                questionGroupVM.StatusList.Add(new SelectListItem()
                {
                    Text = "Active", Value = "true"
                });
                questionGroupVM.StatusList.Add(new SelectListItem()
                {
                    Text = "Inactive", Value = "false"
                });

                questionGroupVM.QuestionGroupInQuestionSearchFilter = new QuestionGroupInQuestionSearchFilter()
                {
                    QuestionGroupId = null,
                    PageNo          = 1,
                    PageSize        = 15,
                    SortField       = "GroupName",
                    SortOrder       = "ASC"
                };

                questionGroupVM.SearchFilter = new QuestionSelectSearchFilter()
                {
                    QuestionName   = string.Empty,
                    QuestionIdList = string.Empty,
                    PageNo         = 1,
                    PageSize       = 15,
                    SortField      = "QuestionName",
                    SortOrder      = "ASC"
                };

                //get sub area section
                return(View(questionGroupVM));
            }

            return(View("Create"));
        }