/// <summary> /// Creates a new LifeOfMinePhase record using async /// </summary> public static async Task CreateAsync(LifeOfMinePhaseDO DO) { SqlParameter _LifeOfMinePhaseTypeID = new SqlParameter("LifeOfMinePhaseTypeID", SqlDbType.VarChar); SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int); SqlParameter _StartDate = new SqlParameter("StartDate", SqlDbType.DateTime); SqlParameter _EndDate = new SqlParameter("EndDate", SqlDbType.DateTime); SqlParameter _Acreage = new SqlParameter("Acreage", SqlDbType.Int); _LifeOfMinePhaseTypeID.Value = DO.LifeOfMinePhaseTypeID; _PermitKey.Value = DO.PermitKey; _StartDate.Value = DO.StartDate; _EndDate.Value = DO.EndDate; _Acreage.Value = DO.Acreage; SqlParameter[] _params = new SqlParameter[] { _LifeOfMinePhaseTypeID, _PermitKey, _StartDate, _EndDate, _Acreage }; string pid = ConfigurationManager.AppSettings["ePermitDAL"]; await DataCommon.ExecuteNonQueryAsync("[dbo].[LifeOfMinePhase_Insert]", _params, pid); }
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; }
/// <summary> /// Gets all LifeOfMinePhase records /// </summary> public static async Task<LifeOfMinePhaseDO[]> GetAllAsync() { string pid = ConfigurationManager.AppSettings["ePermitDAL"]; SafeReader sr = await DataCommon.ExecuteSafeReaderAsync("[dbo].[LifeOfMinePhase_GetAll]", new SqlParameter[] { }, pid); List<LifeOfMinePhaseDO> objs = new List<LifeOfMinePhaseDO>(); while(sr.Read()){ LifeOfMinePhaseDO obj = new LifeOfMinePhaseDO(); obj.LifeOfMinePhaseTypeID = sr.GetString(sr.GetOrdinal("LifeOfMinePhaseTypeID")); obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey")); obj.StartDate = sr.GetDateTime(sr.GetOrdinal("StartDate")); obj.EndDate = sr.GetDateTime(sr.GetOrdinal("EndDate")); obj.Acreage = sr.GetInt32(sr.GetOrdinal("Acreage")); objs.Add(obj); } return objs.ToArray(); }
/// <summary> /// Selects LifeOfMinePhase records by PK /// </summary> public static async Task<LifeOfMinePhaseDO[]> GetByPKAsync(String LifeOfMinePhaseTypeID, Int32 PermitKey) { SqlParameter _LifeOfMinePhaseTypeID = new SqlParameter("LifeOfMinePhaseTypeID", SqlDbType.VarChar); SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int); _LifeOfMinePhaseTypeID.Value = LifeOfMinePhaseTypeID; _PermitKey.Value = PermitKey; SqlParameter[] _params = new SqlParameter[] { _LifeOfMinePhaseTypeID, _PermitKey }; string pid = ConfigurationManager.AppSettings["ePermitDAL"]; SafeReader sr = await DataCommon.ExecuteSafeReaderAsync("[dbo].[LifeOfMinePhase_GetByPK]", _params, pid); List<LifeOfMinePhaseDO> objs = new List<LifeOfMinePhaseDO>(); while(sr.Read()) { LifeOfMinePhaseDO obj = new LifeOfMinePhaseDO(); obj.LifeOfMinePhaseTypeID = sr.GetString(sr.GetOrdinal("LifeOfMinePhaseTypeID")); obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey")); obj.StartDate = sr.GetDateTime(sr.GetOrdinal("StartDate")); obj.EndDate = sr.GetDateTime(sr.GetOrdinal("EndDate")); obj.Acreage = sr.GetInt32(sr.GetOrdinal("Acreage")); objs.Add(obj); } return objs.ToArray(); }
/// <summary> /// Deletes a LifeOfMinePhase record /// </summary> public static async Task<int> DeleteAsync(LifeOfMinePhaseDO DO) { SqlParameter _LifeOfMinePhaseTypeID = new SqlParameter("LifeOfMinePhaseTypeID", SqlDbType.VarChar); SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int); _LifeOfMinePhaseTypeID.Value = DO.LifeOfMinePhaseTypeID; _PermitKey.Value = DO.PermitKey; SqlParameter[] _params = new SqlParameter[] { _LifeOfMinePhaseTypeID, _PermitKey }; string pid = ConfigurationManager.AppSettings["ePermitDAL"]; return await DataCommon.ExecuteScalarAsync("[dbo].[LifeOfMinePhase_Delete]", _params, pid); }