private CSObjectiveDetailViewModel GetCSObjectiveDetailViewModel(string operationNumber, int csObjectiveId, bool isAligned, string pageChart = null)
        {
            CSObjectiveDetailViewModel model = null;

            try
            {
                var response = _monitoringService.GetMonitoringDetail(operationNumber, csObjectiveId, isAligned);
                SetViewBagErrorMessageInvalidResponse(response);

                if (pageChart != null)
                {
                    var fieldAccessList = _securityModelRepository.GetFieldBehaviorByPermissions(
                        IDBContext.Current.Operation,
                        pageChart,
                        IDBContext.Current.Permissions,
                        0,
                        0).ToList();

                    response.CSObjectiveDetail.FieldAccessList = fieldAccessList;
                }

                model = response.CSObjectiveDetail;
            }
            catch (Exception e)
            {
                ViewBag.ErrorMessage = e.Message;
                ViewBag.IsValid      = false;
            }

            return(model);
        }
        public static CSObjectiveDetailViewModel UpdateUseCountrySystemViewModel(this CSObjectiveDetailViewModel model, ClientFieldData[] formData)
        {
            var field = formData.First(x => x.Name == "page-objectiveId");

            if (field != null)
            {
                model.ObjectiveId = field.ConvertToInt(true);
            }

            field = formData.First(x => x.Name == "page-isAligned");
            if (field != null)
            {
                model.IsAligned = field.ConvertToBool() ?? false;
            }

            model.InvestLoans.Clear();
            model.Guarantees.Clear();
            model.InvestGrants.Clear();
            model.TCOperations.Clear();
            model.MIFLoans.Clear();
            model.MIFEquities.Clear();
            model.MIFGuarantees.Clear();
            model.MIFIvestGrants.Clear();
            model.MIFTCOperations.Clear();

            var IunputsInvestLoans = new string[]
            {
                CSMonitoringTypeTable.IBDLoans.ToString() + "-operationId",
                CSMonitoringTypeTable.IBDLoans.ToString() + "-isManual",
                CSMonitoringTypeTable.IBDLoans.ToString() + "-isImport"
            };

            var IunputsGuarantees = new string[]
            {
                CSMonitoringTypeTable.IDBGuarantees.ToString() + "-operationId",
                CSMonitoringTypeTable.IDBGuarantees.ToString() + "-isManual",
                CSMonitoringTypeTable.IDBGuarantees.ToString() + "-isImport"
            };

            var IunputsInvestGrants = new string[]
            {
                CSMonitoringTypeTable.IDBInvestGrants.ToString() + "-operationId",
                CSMonitoringTypeTable.IDBInvestGrants.ToString() + "-isManual",
                CSMonitoringTypeTable.IDBInvestGrants.ToString() + "-isImport"
            };

            var IunputsTCOperations = new string[]
            {
                CSMonitoringTypeTable.IDBTechnicalCoop.ToString() + "-operationId",
                CSMonitoringTypeTable.IDBTechnicalCoop.ToString() + "-isManual",
                CSMonitoringTypeTable.IDBTechnicalCoop.ToString() + "-isImport"
            };

            var IunputsMIFLoans = new string[]
            {
                CSMonitoringTypeTable.MIFLoans.ToString() + "-operationId",
                CSMonitoringTypeTable.MIFLoans.ToString() + "-isManual",
                CSMonitoringTypeTable.MIFLoans.ToString() + "-isImport"
            };

            var IunputsMIFEquities = new string[]
            {
                CSMonitoringTypeTable.MIFEquities.ToString() + "-operationId",
                CSMonitoringTypeTable.MIFEquities.ToString() + "-isManual",
                CSMonitoringTypeTable.MIFEquities.ToString() + "-isImport"
            };

            var IunputsMIFGuarantees = new string[]
            {
                CSMonitoringTypeTable.MIFGuarantees.ToString() + "-operationId",
                CSMonitoringTypeTable.MIFGuarantees.ToString() + "-isManual",
                CSMonitoringTypeTable.MIFGuarantees.ToString() + "-isImport"
            };

            var IunputsMIFIvestGrants = new string[]
            {
                CSMonitoringTypeTable.MIFInvestGrants.ToString() + "-operationId",
                CSMonitoringTypeTable.MIFInvestGrants.ToString() + "-isManual",
                CSMonitoringTypeTable.MIFInvestGrants.ToString() + "-isImport"
            };

            var IunputsMIFTCOperations = new string[]
            {
                CSMonitoringTypeTable.MIFTechnicalCoop.ToString() + "-operationId",
                CSMonitoringTypeTable.MIFTechnicalCoop.ToString() + "-isManual",
                CSMonitoringTypeTable.MIFTechnicalCoop.ToString() + "-isImport"
            };

            model.InvestLoans.InitializeOperations(IunputsInvestLoans, formData);
            model.Guarantees.InitializeOperations(IunputsGuarantees, formData);
            model.InvestGrants.InitializeOperations(IunputsInvestGrants, formData);
            model.TCOperations.InitializeOperations(IunputsTCOperations, formData);
            model.MIFLoans.InitializeOperations(IunputsMIFLoans, formData);
            model.MIFEquities.InitializeOperations(IunputsMIFEquities, formData);
            model.MIFGuarantees.InitializeOperations(IunputsMIFGuarantees, formData);
            model.MIFIvestGrants.InitializeOperations(IunputsMIFIvestGrants, formData);
            model.MIFTCOperations.InitializeOperations(IunputsMIFTCOperations, formData);
            return(model);
        }