Пример #1
0
        public static void UpdateTemplate(this EditTemplatePageViewModel <EditTemplateStandardizedViewModel> model, ClientFieldData[] formData)
        {
            model.UpdateTemplateCommon(formData);

            model.Template.Specific.BusinessLines = formData.GetSimpleLevelData("BusinessLine");
            model.Template.Specific.OutputGroups  = formData.GetSimpleLevelData("OutputGroups");
        }
Пример #2
0
        private EditTemplatePageViewModel GetTemplateViewModel(int templateId)
        {
            var havePermission = SetViewBagGlobalPermissionAndCheckAny(ActionEnum.FWIndicatorTemplateWritePermission);

            EditTemplatePageViewModel <EditTemplateFrameworkViewModel> result = null;

            if (havePermission)
            {
                result = new EditTemplatePageViewModel <EditTemplateFrameworkViewModel>()
                {
                    ControllerName = base.ControllerName
                };

                var response = _resultFrameworkService.GetTemplate(templateId);

                if (response.IsValid)
                {
                    result.Template = (EditTemplateViewModel <EditTemplateFrameworkViewModel>)response.Template;
                }

                SetViewBagErrorMessageInvalidResponse(response);
            }
            else
            {
                ViewBag.ErrorMessage = Localization.GetText(FRIENDLY_PERMISSION_ERROR);
            }

            return(result);
        }
Пример #3
0
        public static void UpdateTemplate(this EditTemplatePageViewModel <EditTemplateFrameworkViewModel> model, ClientFieldData[] formData)
        {
            model.UpdateTemplateCommon(formData);

            model.Template.Specific.Types           = formData.GetSimpleLevelData("Type");
            model.Template.Specific.PriorityAreas   = formData.GetMultiLevelData("PriorityArea");
            model.Template.Specific.Disaggregations = formData.GetMultiLevelData("Disaggregation");
        }
Пример #4
0
        private static void UpdateTemplateCommon(this EditTemplatePageViewModel model, ClientFieldData[] formData)
        {
            ClientFieldData field = null;

            field = formData.FirstOrDefault(x => x.Name == "version");
            if (field != null)
            {
                model.Template.Common.Version = field.Value;
            }

            field = formData.FirstOrDefault(x => x.Name == "description");
            if (field != null)
            {
                model.Template.Common.Description = field.Value;
            }

            // Technical Field Data
            // Remove default technical field
            model.Template.Common.TechnicalFields.RemoveAll(x => x.TechnicalFieldTemplateId == 0);
            var techincals = formData.Where(x => x.Name == "technicalFieldName" ||
                                            x.Name.Contains("typeTF-new-") ||
                                            x.Name.Contains("typeTFValue-") ||
                                            x.Name.Contains("IsActive"));

            var oldTechnical = techincals.Where(x => x.ExtraData.ContainsKey("data-persist-old-id"));
            var newTechnical = techincals.Where(x => x.ExtraData.ContainsKey("data-persist-new-id"));

            var oldGrouped = oldTechnical.GroupBy(x => x.ExtraData.FirstOrDefault(y => y.Key == "data-persist-old-id"));
            var newGrouped = newTechnical.GroupBy(x => x.ExtraData.FirstOrDefault(y => y.Key == "data-persist-new-id"));

            List <TechnicalFieldViewModel> newTechnicalFields = new List <TechnicalFieldViewModel>();

            foreach (var oldItem in oldGrouped)
            {
                var technicalModel = model.Template.Common.TechnicalFields.First(x => x.TechnicalFieldTemplateId.ToString() == oldItem.Key.Value);

                field = oldItem.FirstOrDefault(x => x.Name == "technicalFieldName");
                if (field != null)
                {
                    technicalModel.Name = field.Value;
                }

                field = oldItem.FirstOrDefault(x => x.Name.Contains("IsActive"));
                if (field != null)
                {
                    technicalModel.IsActive = !GetBoolValue(field.Value);
                }

                field = oldItem.FirstOrDefault(x => x.Name.Contains("typeTFValue-"));
                if (field != null)
                {
                    technicalModel.Type = field.Value == "text" ? TechnicalFieldTypeEnum.Text : TechnicalFieldTypeEnum.Bool;
                }

                newTechnicalFields.Add(technicalModel);
            }

            foreach (var newItem in newGrouped)
            {
                var technicalModel = new TechnicalFieldViewModel();

                field = newItem.FirstOrDefault(x => x.Name == "technicalFieldName");
                if (field != null)
                {
                    technicalModel.Name = field.Value;
                }

                field = newItem.FirstOrDefault(x => x.Name.Contains("typeTF-new-"));
                if (field != null)
                {
                    technicalModel.Type = field.Value == "text" ? TechnicalFieldTypeEnum.Text : TechnicalFieldTypeEnum.Bool;
                }

                field = newItem.FirstOrDefault(x => x.Name == "IsActive");
                if (field != null)
                {
                    technicalModel.IsActive = !GetBoolValue(field.Value);
                }

                newTechnicalFields.Add(technicalModel);
            }

            model.Template.Common.TechnicalFields = newTechnicalFields;
        }
Пример #5
0
 public static void UpdateTemplate(this EditTemplatePageViewModel model, ClientFieldData[] formData)
 {
     model.UpdateTemplateCommon(formData);
 }