コード例 #1
0
ファイル: AnalysisController.cs プロジェクト: joyoon/mb
        private Criteria2ViewModelItem GetCriteria2ViewModel(int recId, string recName, Criteria2 criteriaData)
        {
            //criteriaData.Criteria21a.CalcScore();
            Criteria2ViewModelItem model;

            if (criteriaData == null)
            {
                model = new Criteria2ViewModelItem()
                {
                    RecommendationId = recId,
                    RecommendationName = recName,
                    CriteriaId = 0,
                    Criteria21a = new Criteria21aViewModel(),
                    Criteria21b = new Criteria21bViewModel()
                    {
                        NetCagesAndPens = new Criteria21bViewModel.NetCagesAndPensViewModel(),
                        Ponds = new Criteria21bViewModel.PondsViewModel(),
                        RacewaysOrTanks = new Criteria21bViewModel.RacewaysOrTanksViewModel(),
                        Other = new Criteria21bViewModel.OtherViewModel()
                    },
                    Criteria22a = new Criteria22aViewModel(),
                    Criteria22b = new Criteria22bViewModel(),
                };
            }
            else
            {
                model = new Criteria2ViewModelItem()
                {
                    RecommendationId = recId,
                    RecommendationName = recName,
                    CriteriaId = criteriaData.Id,
                    ProvideData = criteriaData.ProvideData,
                    RapidScore = criteriaData.RapidScore,
                    Criteria21a = criteriaData.Criteria21a == null
                        ? new Criteria21aViewModel()
                        : new Criteria21aViewModel()
                            {
                                EFCR = criteriaData.Criteria21a.EFCR,
                                FertilizerNInput = criteriaData.Criteria21a.NitrogenInput,
                                ProteinContentFish = criteriaData.Criteria21a.ProteinContentHarvested,
                                ProteinContentOfFeed = criteriaData.Criteria21a.ProteinContentFeed,
                                Score = criteriaData.Criteria21a.Score
                            },
                    Criteria21b = criteriaData.Criteria21b == null
                        ? new Criteria21bViewModel()
                        : new Criteria21bViewModel()
                        {
                            ProductionSystemType = criteriaData.Criteria21b.ProductionSystemType,
                            BasicScore = criteriaData.Criteria21b.BasicScore,
                            NetCagesAndPens = new Criteria21bViewModel.NetCagesAndPensViewModel()
                            {
                                BasicScore = criteriaData.Criteria21b.ProductionSystemOpenModified,
                                BasicScoreValue = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.netCagesAndPens
                                    && criteriaData.Criteria21b.ProductionSystemOpenModified == ProductionSystemOpenModified.Modified
                                    ? criteriaData.Criteria21b.BasicScore
                                    : null,
                                OtherAdjustment = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.netCagesAndPens
                                    ? criteriaData.Criteria21b.AdjustmentOther
                                    : false,
                                OtherAdjustmentValue = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.netCagesAndPens
                                    ? criteriaData.Criteria21b.AdjustmentOtherAmount
                                    : null
                            },
                            Ponds = new Criteria21bViewModel.PondsViewModel()
                            {
                                BasicScore = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.ponds
                                    ? criteriaData.Criteria21b.BasicScore
                                    : null,
                                BasicScoreOther = false,
                                OtherAdjustment = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.ponds
                                    ? criteriaData.Criteria21b.AdjustmentOther
                                    : false,
                                OtherAdjustmentValue = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.ponds
                                    ? criteriaData.Criteria21b.AdjustmentOtherAmount
                                    : null,
                                ProperSludgeDisposalAdjustment = criteriaData.Criteria21b.AdjustmentSludge.ToString(),
                                SettlingPondAdjustment = criteriaData.Criteria21b.AdjustmentSettlingPond.ToString(),
                                DischargedHarvestWaterAdjustment = criteriaData.Criteria21b.AdjustmentSettlingPondForHarvest.ToString()
                            },
                            RacewaysOrTanks = new Criteria21bViewModel.RacewaysOrTanksViewModel()
                            {
                                BasicScore = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.racewaysOrTanks
                                    ? criteriaData.Criteria21b.BasicScore
                                    : null,
                                BasicScoreOther = false,
                                InappropriateDisposal = criteriaData.Criteria21b.InappropriateDisposal.ToString(),
                                OtherAdjustment = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.racewaysOrTanks
                                    ? criteriaData.Criteria21b.AdjustmentOther
                                    : false,
                                OtherAdjustmentValue = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.racewaysOrTanks
                                    ? criteriaData.Criteria21b.AdjustmentOtherAmount
                                    : null
                            },
                            Other = new Criteria21bViewModel.OtherViewModel()
                            {
                                BasicScore = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.other
                                    ? criteriaData.Criteria21b.BasicScore
                                    : null,
                                IMTA = criteriaData.Criteria21b.IMTA,
                                IMTAAdjustment = criteriaData.Criteria21b.IMTAAdjustment,
                                OtherAdjustment = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.other
                                    ? criteriaData.Criteria21b.AdjustmentOther
                                    : false,
                                OtherAdjustmentValue = criteriaData.Criteria21b.ProductionSystemType == ProductionSystemType.other
                                    ? criteriaData.Criteria21b.AdjustmentOtherAmount
                                    : null
                            }
                        },
                    Criteria22a = criteriaData.Criteria22a == null
                        ? new Criteria22aViewModel()
                        : new Criteria22aViewModel()
                            {
                                A = criteriaData.Criteria22a.A,
                                B = criteriaData.Criteria22a.B,
                                C = criteriaData.Criteria22a.C,
                                D = criteriaData.Criteria22a.D,
                                E = criteriaData.Criteria22a.E
                            },
                    Criteria22b = criteriaData.Criteria22b == null
                        ? new Criteria22bViewModel()
                        : new Criteria22bViewModel()
                            {
                                A = criteriaData.Criteria22b.A,
                                B = criteriaData.Criteria22b.B,
                                C = criteriaData.Criteria22b.C,
                                D = criteriaData.Criteria22b.D,
                                E = criteriaData.Criteria22b.E
                            }
                    };
            }

            return model;
        }
コード例 #2
0
ファイル: CriteriaService.cs プロジェクト: joyoon/mb
 public Criteria2 Save(Criteria2 criteria)
 {
     return this.criteria2Repository.Attach(criteria);
 }
コード例 #3
0
ファイル: Criteria2Repository.cs プロジェクト: joyoon/mb
        public Criteria2 Attach(Criteria2 model)
        {
            RunInTransaction(session => session.SaveOrUpdate(model));

            return model;
        }