Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SubModuleItemDTOConverter"/> class.
 /// </summary>
 /// <param name="subModuleCategoryModel">
 /// The sub Module Category Model.
 /// </param>
 /// <param name="subModuleItemThemeModel">
 /// The sub module item theme model.
 /// </param>
 /// <param name="subModuleItemModel">
 /// The sub module item model.
 /// </param>
 /// <param name="userModel">
 /// The user Model.
 /// </param>
 public SubModuleItemDTOConverter(
     SubModuleCategoryModel subModuleCategoryModel,
     SubModuleItemThemeModel subModuleItemThemeModel,
     SubModuleItemModel subModuleItemModel,
     UserModel userModel)
 {
     this.subModuleCategoryModel  = subModuleCategoryModel;
     this.subModuleItemThemeModel = subModuleItemThemeModel;
     this.subModuleItemModel      = subModuleItemModel;
     this.userModel = userModel;
 }
Пример #2
0
        public JsonResult GetBaseSubModuleItemList()
        {
            var subModuleItemListObj = this.subModuleItemService.GetAllBaseSubModuleItem();
            List <SubModuleItemModel> subModuleItemVMList = new List <SubModuleItemModel>();

            foreach (var subModuleItem in subModuleItemListObj)
            {
                SubModuleItemModel subModuleItemTemp = new SubModuleItemModel();
                subModuleItemTemp.Id   = subModuleItem.Id;
                subModuleItemTemp.Name = subModuleItem.Name;
                if (subModuleItem.SubModuleId != null)
                {
                    subModuleItemTemp.ModuleId = subModuleItem.SubModule.ModuleId;
                }
                subModuleItemTemp.SubModuleId = subModuleItem.SubModuleId;
                subModuleItemTemp.Ordering    = subModuleItem.Ordering;
                if (subModuleItem.SubModuleId != null)
                {
                    subModuleItemTemp.SubModuleName = subModuleItem.SubModule.Name;
                    if (subModuleItem.SubModule.ModuleId != null)
                    {
                        subModuleItemTemp.ModuleName = subModuleItem.SubModule.Module.Name;
                    }
                }

                subModuleItemTemp.UrlPath    = subModuleItem.UrlPath;
                subModuleItemTemp.IsBaseItem = subModuleItem.IsBaseItem;
                subModuleItemTemp.BaseItemId = subModuleItem.BaseItemId;
                if (subModuleItemTemp.BaseItemId != null)
                {
                    subModuleItemTemp.BaseItemName = subModuleItem.SubModuleItem2.Name;
                }

                if (subModuleItem.IsActive != null)
                {
                    subModuleItemTemp.IsActive = subModuleItem.IsActive.Value;
                }

                //subModuleItemTemp.IsNotificationItem = subModuleItem.IsNotificationItem;
                //subModuleItemTemp.IsWorkflowItem = subModuleItem.IsWorkflowItem;

                subModuleItemVMList.Add(subModuleItemTemp);
            }
            return(Json(subModuleItemVMList.OrderBy(x => x.Name), JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        /// <summary>
        /// The convert DTO.
        /// </summary>
        /// <param name="itemDTO">
        /// The user.
        /// </param>
        /// <param name="instance">
        /// The instance.
        /// </param>
        /// <returns>
        /// The <see cref="Test"/>.
        /// </returns>
        private Test ConvertDto(TestDTO itemDTO, Test instance)
        {
            instance = instance ?? new Test();
            instance.TestName = itemDTO.testName;
            instance.Description = itemDTO.description;
            instance.InstructionTitle = itemDTO.instructionTitle;
            instance.InstructionDescription = itemDTO.instructionDescription;
            instance.PassingScore = itemDTO.passingScore;
            instance.ScoreFormat = itemDTO.scoreFormat;
            instance.TimeLimit = itemDTO.timeLimit;

            instance.SubModuleItem = itemDTO.subModuleItemId.HasValue ? SubModuleItemModel.GetOneById(itemDTO.subModuleItemId.Value).Value : null;
            instance.ScoreType = itemDTO.scoreTypeId.HasValue ? ScoreTypeModel.GetOneById(itemDTO.scoreTypeId.Value).Value ?? ScoreTypeModel.GetOneById(1).Value : this.ScoreTypeModel.GetOneById(1).Value;
            if (instance.SubModuleItem != null)
            {
                instance.SubModuleItem.DateModified = DateTime.Now;
                SubModuleItemModel.RegisterSave(instance.SubModuleItem);
            }

            return instance;
        }
Пример #4
0
 public SubModuleItemDTO[] GetSurveySMItemsByUserId(int userId)
 {
     return(SubModuleItemModel.GetSurveySubModuleItemsByUserId(userId).ToArray());
 }
Пример #5
0
        internal static Distractor ConvertDto(DistractorDTO q, Distractor instance, bool updateQuestionDate,
                                              FileModel fileModel, QuestionModel questionModel, UserModel userModel, SubModuleItemModel subModuleItemModel)
        {
            instance                 = instance ?? new Distractor();
            instance.IsActive        = q.isActive;
            instance.DistractorName  = q.distractor;
            instance.DistractorOrder = q.distractorOrder;
            instance.Score           = q.score;
            instance.IsCorrect       = q.isCorrect;
            if (instance.IsTransient())
            {
                instance.DateCreated = DateTime.Now;
            }

            instance.DateModified   = DateTime.Now;
            instance.Image          = q.imageId.HasValue ? fileModel.GetOneById(q.imageId.Value).Value : null;
            instance.LeftImage      = q.leftImageId.HasValue ? fileModel.GetOneById(q.leftImageId.Value).Value : null;
            instance.RightImage     = q.rightImageId.HasValue ? fileModel.GetOneById(q.rightImageId.Value).Value : null;
            instance.Question       = q.questionId.HasValue ? questionModel.GetOneById(q.questionId.Value).Value : null;
            instance.ModifiedBy     = q.modifiedBy.HasValue ? userModel.GetOneById(q.modifiedBy.Value).Value : null;
            instance.CreatedBy      = q.createdBy.HasValue ? userModel.GetOneById(q.createdBy.Value).Value : null;
            instance.DistractorType = q.distractorType;
            if (instance.Question != null && updateQuestionDate)
            {
                var subModuleItem = instance.Question.SubModuleItem;
                subModuleItem.DateModified = DateTime.Now;
                subModuleItemModel.RegisterSave(subModuleItem);
            }

            return(instance);
        }
Пример #6
0
        public JsonResult GetModuleListWithSubmodule()
        {
            var LoggedUser = UserSession.GetUserFromSession();

            if (LoggedUser != null)
            {
                var moduleListObj = this.moduleService.GetAllModuleByRoleId(LoggedUser.RoleId);
                List <ModuleModel> moduleVMList = new List <ModuleModel>();

                foreach (var module in moduleListObj)
                {
                    ModuleModel moduleTemp = new ModuleModel();
                    moduleTemp.Id        = module.Id;
                    moduleTemp.Name      = module.Name;
                    moduleTemp.ImageName = module.ImageName;
                    moduleTemp.Ordering  = module.Ordering;

                    if (module.IsActive != null)
                    {
                        moduleTemp.IsActive = module.IsActive.Value;
                    }

                    if (module.SubModules.Any())
                    {
                        foreach (var moduleSubModule in module.SubModules)
                        {
                            var isSubModuleActive = moduleSubModule.IsActive ?? false;
                            if (isSubModuleActive)
                            {
                                var submodule = new SubModuleModel();
                                submodule.Id       = moduleSubModule.Id;
                                submodule.Name     = moduleSubModule.Name;
                                submodule.ModuleId = moduleSubModule.ModuleId;
                                submodule.Ordering = moduleSubModule.Ordering;


                                if (moduleSubModule.SubModuleItems.Any())
                                {
                                    foreach (var subModuleItem in moduleSubModule.SubModuleItems)
                                    {
                                        var isSubModuleItemActive = subModuleItem.IsActive ?? false;
                                        if (isSubModuleItemActive)
                                        {
                                            var subModuleItemVm = new SubModuleItemModel();
                                            subModuleItemVm.Id          = subModuleItem.Id;
                                            subModuleItemVm.Ordering    = subModuleItem.Ordering;
                                            subModuleItemVm.Name        = subModuleItem.Name;
                                            subModuleItemVm.ModuleId    = subModuleItem.SubModule.Module.Id;
                                            subModuleItemVm.SubModuleId = subModuleItem.SubModule.Id;

                                            submodule.SubModuleItems.Add(subModuleItemVm);
                                        }
                                    }
                                }

                                moduleTemp.SubModules.Add(submodule);
                            }
                        }
                    }

                    moduleVMList.Add(moduleTemp);
                }
                return(Json(moduleVMList, JsonRequestBehavior.AllowGet));
            }
            return(null);
        }
Пример #7
0
 public SubModuleItemDTO[] GetTestSMItemsByUserId(int userId)
 {
     return SubModuleItemModel.GetTestSubModuleItemsByUserId(userId).ToArray();
 }