public LifeOfMineBO WriteDataToTables(int PermitKey, ModelStateDictionary ModelState) { LifeOfMineBO data = new LifeOfMineBO(); data.LifeOfMineYears = this.LifeOfMineYears; data.AnnualAnticipatedProductionInTons = this.AnnualAnticipatedProductionInTons; data.TotalAnticipatedProductionInTons = this.TotalAnticipatedProductionInTons; data.LifeOfMineComments = this.LifeOfMineComments; data.EndOfLifeActivitiesComments = this.EndOfLifeActivitiesComments; data.LifeOfMinePhases = new List<LifeOfMinePhaseDO>(); data.PermitKey = PermitKey; if (this.TopsoilRemovalStartDate.HasValue & this.TopsoilRemovalEndDate.HasValue & this.TopsoilRemovalAcreage.HasValue) { LifeOfMinePhaseDO NewRow = new LifeOfMinePhaseDO() { LifeOfMinePhaseTypeID = "Topsoil Removal", PermitKey = PermitKey, StartDate = this.TopsoilRemovalStartDate.Value, EndDate = this.TopsoilRemovalEndDate.Value, Acreage = this.TopsoilRemovalAcreage.Value }; data.LifeOfMinePhases.Add(NewRow); } else { if (this.TopsoilRemovalStartDate.HasValue | this.TopsoilRemovalEndDate.HasValue | this.TopsoilRemovalAcreage.HasValue) { ModelState.AddModelError("", "Topsoil Removal fields must be all blank or all complete"); } } if (this.OverburdenRemovalStartDate.HasValue & this.OverburdenRemovalEndDate.HasValue & this.OverburdenRemovalAcreage.HasValue) { LifeOfMinePhaseDO NewRow = new LifeOfMinePhaseDO() { LifeOfMinePhaseTypeID = "Overburden Removal", PermitKey = PermitKey, StartDate = this.OverburdenRemovalStartDate.Value, EndDate = this.OverburdenRemovalEndDate.Value, Acreage = this.OverburdenRemovalAcreage.Value }; data.LifeOfMinePhases.Add(NewRow); } else { if (this.OverburdenRemovalStartDate.HasValue | this.OverburdenRemovalEndDate.HasValue | this.OverburdenRemovalAcreage.HasValue) { ModelState.AddModelError("", "Overburden Removal fields must be all blank or all complete"); } } if (this.CoalRemovalStartDate.HasValue & this.CoalRemovalEndDate.HasValue & this.CoalRemovalAcreage.HasValue) { LifeOfMinePhaseDO NewRow = new LifeOfMinePhaseDO() { LifeOfMinePhaseTypeID = "Coal Removal", PermitKey = PermitKey, StartDate = this.CoalRemovalStartDate.Value, EndDate = this.CoalRemovalEndDate.Value, Acreage = this.CoalRemovalAcreage.Value }; data.LifeOfMinePhases.Add(NewRow); } else { if (this.CoalRemovalStartDate.HasValue | this.CoalRemovalEndDate.HasValue | this.CoalRemovalAcreage.HasValue) { ModelState.AddModelError("", "Coal Removal fields must be all blank or all complete"); } } if (this.BackfillingAndGradingStartDate.HasValue & this.BackfillingAndGradingEndDate.HasValue & this.BackfillingAndGradingAcreage.HasValue) { LifeOfMinePhaseDO NewRow = new LifeOfMinePhaseDO() { LifeOfMinePhaseTypeID = "Backfilling and Grading", PermitKey = PermitKey, StartDate = this.BackfillingAndGradingStartDate.Value, EndDate = this.BackfillingAndGradingEndDate.Value, Acreage = this.BackfillingAndGradingAcreage.Value }; data.LifeOfMinePhases.Add(NewRow); } else { if (this.BackfillingAndGradingStartDate.HasValue | this.BackfillingAndGradingEndDate.HasValue | this.BackfillingAndGradingAcreage.HasValue) { ModelState.AddModelError("", "Backfilling and Grading fields must be all blank or all complete"); } } if (this.TopsoilRedistributionStartDate.HasValue & this.TopsoilRedistributionEndDate.HasValue & this.TopsoilRedistributionAcreage.HasValue) { LifeOfMinePhaseDO NewRow = new LifeOfMinePhaseDO() { LifeOfMinePhaseTypeID = "Topsoil Redistribution", PermitKey = PermitKey, StartDate = this.TopsoilRedistributionStartDate.Value, EndDate = this.TopsoilRedistributionEndDate.Value, Acreage = this.TopsoilRedistributionAcreage.Value }; data.LifeOfMinePhases.Add(NewRow); } else { if (this.TopsoilRedistributionStartDate.HasValue | this.TopsoilRedistributionEndDate.HasValue | this.TopsoilRedistributionAcreage.HasValue) { ModelState.AddModelError("", "Topsoil Redistribution fields must be all blank or all complete"); } } if (this.RevegetationStartDate.HasValue & this.RevegetationEndDate.HasValue & this.RevegetationAcreage.HasValue) { LifeOfMinePhaseDO NewRow = new LifeOfMinePhaseDO() { LifeOfMinePhaseTypeID = "Revegetation", PermitKey = PermitKey, StartDate = this.RevegetationStartDate.Value, EndDate = this.RevegetationEndDate.Value, Acreage = this.RevegetationAcreage.Value }; data.LifeOfMinePhases.Add(NewRow); } else { if (this.RevegetationStartDate.HasValue | this.RevegetationEndDate.HasValue | this.RevegetationAcreage.HasValue) { ModelState.AddModelError("", "Revegetation fields must be all blank or all complete"); } } if (this.RemovalOfFacilitiesAndStructuresStartDate.HasValue & this.RemovalOfFacilitiesAndStructuresEndDate.HasValue & this.RemovalOfFacilitiesAndStructuresAcreage.HasValue) { LifeOfMinePhaseDO NewRow = new LifeOfMinePhaseDO() { LifeOfMinePhaseTypeID = "Removal of Facilities and Structures", PermitKey = PermitKey, StartDate = this.RemovalOfFacilitiesAndStructuresStartDate.Value, EndDate = this.RemovalOfFacilitiesAndStructuresEndDate.Value, Acreage = this.RemovalOfFacilitiesAndStructuresAcreage.Value }; data.LifeOfMinePhases.Add(NewRow); } else { if (this.RemovalOfFacilitiesAndStructuresStartDate.HasValue | this.RemovalOfFacilitiesAndStructuresEndDate.HasValue | this.RemovalOfFacilitiesAndStructuresAcreage.HasValue) { ModelState.AddModelError("", "Removal of Facilities and Structures fields must be all blank or all complete"); } } if (this.RemovalOfDrainageControlStructuresStartDate.HasValue & this.RemovalOfDrainageControlStructuresEndDate.HasValue & this.RemovalOfDrainageControlStructuresAcreage.HasValue) { LifeOfMinePhaseDO NewRow = new LifeOfMinePhaseDO() { LifeOfMinePhaseTypeID = "Removal of Drainage Control Structures", PermitKey = PermitKey, StartDate = this.RemovalOfDrainageControlStructuresStartDate.Value, EndDate = this.RemovalOfDrainageControlStructuresEndDate.Value, Acreage = this.RemovalOfDrainageControlStructuresAcreage.Value }; data.LifeOfMinePhases.Add(NewRow); } else { if (this.RemovalOfDrainageControlStructuresStartDate.HasValue | this.RemovalOfDrainageControlStructuresEndDate.HasValue | this.RemovalOfDrainageControlStructuresAcreage.HasValue) { ModelState.AddModelError("", "Removal of Drainage Control Structures fields must be all blank or all complete"); } } if (this.RemovalOfHaulRoadAndAccessRoadStartDate.HasValue & this.RemovalOfHaulRoadAndAccessRoadEndDate.HasValue & this.RemovalOfHaulRoadAndAccessRoadAcreage.HasValue) { LifeOfMinePhaseDO NewRow = new LifeOfMinePhaseDO() { LifeOfMinePhaseTypeID = "Removal of Haul Road and Access Road", PermitKey = PermitKey, StartDate = this.RemovalOfHaulRoadAndAccessRoadStartDate.Value, EndDate = this.RemovalOfHaulRoadAndAccessRoadEndDate.Value, Acreage = this.RemovalOfHaulRoadAndAccessRoadAcreage.Value }; data.LifeOfMinePhases.Add(NewRow); } else { if (this.RemovalOfHaulRoadAndAccessRoadStartDate.HasValue | this.RemovalOfHaulRoadAndAccessRoadEndDate.HasValue | this.RemovalOfHaulRoadAndAccessRoadAcreage.HasValue) { ModelState.AddModelError("", "Removal of Haul Road and Access Road fields must be all blank or all complete"); } } return data; }
public TimeTableVM(LifeOfMineBO BO) { this.LifeOfMineYears = BO.LifeOfMineYears; this.AnnualAnticipatedProductionInTons = BO.AnnualAnticipatedProductionInTons; this.TotalAnticipatedProductionInTons = BO.TotalAnticipatedProductionInTons; this.LifeOfMineComments = BO.LifeOfMineComments; this.EndOfLifeActivitiesComments = BO.EndOfLifeActivitiesComments; if (BO.LifeOfMinePhases.Exists(x => x.LifeOfMinePhaseTypeID == "Topsoil Removal")) { this.TopsoilRemovalStartDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Topsoil Removal").StartDate; this.TopsoilRemovalEndDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Topsoil Removal").EndDate; this.TopsoilRemovalAcreage = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Topsoil Removal").Acreage; } if (BO.LifeOfMinePhases.Exists(x => x.LifeOfMinePhaseTypeID == "Overburden Removal")) { this.OverburdenRemovalStartDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Overburden Removal").StartDate; this.OverburdenRemovalEndDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Overburden Removal").EndDate; this.OverburdenRemovalAcreage = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Overburden Removal").Acreage; } if (BO.LifeOfMinePhases.Exists(x => x.LifeOfMinePhaseTypeID == "Coal Removal")) { this.CoalRemovalStartDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Coal Removal").StartDate; this.CoalRemovalEndDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Coal Removal").EndDate; this.CoalRemovalAcreage = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Coal Removal").Acreage; } if (BO.LifeOfMinePhases.Exists(x => x.LifeOfMinePhaseTypeID == "Backfilling and Grading")) { this.BackfillingAndGradingStartDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Backfilling and Grading").StartDate; this.BackfillingAndGradingEndDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Backfilling and Grading").EndDate; this.BackfillingAndGradingAcreage = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Backfilling and Grading").Acreage; } if (BO.LifeOfMinePhases.Exists(x => x.LifeOfMinePhaseTypeID == "Topsoil Redistribution")) { this.TopsoilRedistributionStartDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Topsoil Redistribution").StartDate; this.TopsoilRedistributionEndDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Topsoil Redistribution").EndDate; this.TopsoilRedistributionAcreage = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Topsoil Redistribution").Acreage; } if (BO.LifeOfMinePhases.Exists(x => x.LifeOfMinePhaseTypeID == "Revegetation")) { this.RevegetationStartDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Revegetation").StartDate; this.RevegetationEndDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Revegetation").EndDate; this.RevegetationAcreage = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Revegetation").Acreage; } if (BO.LifeOfMinePhases.Exists(x => x.LifeOfMinePhaseTypeID == "Removal of Facilities and Structures")) { this.RemovalOfFacilitiesAndStructuresStartDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Removal of Facilities and Structures").StartDate; this.RemovalOfFacilitiesAndStructuresEndDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Removal of Facilities and Structures").EndDate; this.RemovalOfFacilitiesAndStructuresAcreage = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Removal of Facilities and Structures").Acreage; } if (BO.LifeOfMinePhases.Exists(x => x.LifeOfMinePhaseTypeID == "Removal of Drainage Control Structures")) { this.RemovalOfDrainageControlStructuresStartDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Removal of Drainage Control Structures").StartDate; this.RemovalOfDrainageControlStructuresEndDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Removal of Drainage Control Structures").EndDate; this.RemovalOfDrainageControlStructuresAcreage = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Removal of Drainage Control Structures").Acreage; } if (BO.LifeOfMinePhases.Exists(x => x.LifeOfMinePhaseTypeID == "Removal of Haul Road and Access Road")) { this.RemovalOfHaulRoadAndAccessRoadStartDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Removal of Haul Road and Access Road").StartDate; this.RemovalOfHaulRoadAndAccessRoadEndDate = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Removal of Haul Road and Access Road").EndDate; this.RemovalOfHaulRoadAndAccessRoadAcreage = BO.LifeOfMinePhases.Find(x => x.LifeOfMinePhaseTypeID == "Removal of Haul Road and Access Road").Acreage; } }