Example #1
0
        public ResourceBundleAttribute Clone()
        {
            ResourceBundleAttribute clone = new ResourceBundleAttribute();

            clone.CommercialOperationEndDate   = this.CommercialOperationEndDate;
            clone.CommercialOperationStartDate = this.CommercialOperationStartDate;
            clone.DateEffective = this.DateEffective;
            clone.DateEnd       = this.DateEnd;
            clone.DateReplaced  = this.DateReplaced;
            clone.DependableGenerationCapacity  = this.DependableGenerationCapacity;
            clone.EffectiveLoadCarryingCapacity = this.EffectiveLoadCarryingCapacity;
            clone.OriginalId = this.OriginalId;
            clone.PotentialIncludeCapacity   = this.PotentialIncludeCapacity;
            clone.ResourceBundleId           = this.ResourceBundleId;
            clone.ResourcePlanId             = this.ResourcePlanId;
            clone.SystemCapacity             = this.SystemCapacity;
            clone.MaximumPowerOutputCapacity = this.MaximumPowerOutputCapacity;
            clone.NitsDesignatedCapacity     = this.NitsDesignatedCapacity;
            clone.IsDesignated          = this.IsDesignated;
            clone.NamePlateCapacityInMW = this.NamePlateCapacityInMW;
            clone.FirmEnergy            = this.FirmEnergy;
            clone.TotalEnergy           = this.TotalEnergy;
            clone.UnitEnergyCostStart   = this.UnitEnergyCostStart;
            clone.UnitEnergyCostEnd     = this.UnitEnergyCostEnd;
            clone.EnergyAvailableYear   = this.EnergyAvailableYear;
            clone.AverageEnergy         = this.AverageEnergy;
            clone.Probability           = this.Probability;
            clone.EnergyEfficiency      = this.EnergyEfficiency;
            clone.DiscountRateId        = this.DiscountRateId;
            return(clone);
        }
        public void SaveResourceBundleAttributeAgainstPhase(ResourceBundleAttribute newRba, ref ResourceBundleAttribute currentRba)
        {
            ResourceBundleAttribute existingRba = this.Context.ResourceBundleAttributes.FirstOrDefault(ra => ra.ResourcePlanId == newRba.ResourcePlanId &&
                                                                                                       ra.ProjectPhaseId == newRba.ProjectPhaseId &&
                                                                                                       ra.ResourceBundleId == newRba.ResourceBundleId);

            if (existingRba != null)
            {
                currentRba = existingRba.Clone();
                existingRba.DateUpdated   = DateTime.Now;
                existingRba.UserUpdatedId = newRba.UserCreatedId;
                existingRba.CommercialOperationEndDate   = newRba.CommercialOperationEndDate;
                existingRba.CommercialOperationStartDate = newRba.CommercialOperationStartDate;
                existingRba.DateEffective = newRba.DateEffective;
                existingRba.DateEnd       = newRba.DateEnd;
                existingRba.DateReplaced  = newRba.DateReplaced;
                existingRba.DependableGenerationCapacity  = newRba.DependableGenerationCapacity;
                existingRba.EffectiveLoadCarryingCapacity = newRba.EffectiveLoadCarryingCapacity;
                existingRba.OriginalId = newRba.OriginalId;
                existingRba.PotentialIncludeCapacity = newRba.PotentialIncludeCapacity;
                existingRba.SystemCapacity           = newRba.SystemCapacity;
                existingRba.NitsDesignatedCapacity   = newRba.NitsDesignatedCapacity;
                existingRba.NamePlateCapacityInMW    = newRba.NamePlateCapacityInMW;
                existingRba.IsDesignated             = newRba.IsDesignated;
            }
            else
            {
                this.Context.ResourceBundleAttributes.InsertOnSubmit(newRba);
            }
            this.Context.SubmitChanges();
        }
        /// <summary>
        /// Checks if a db record exists with the same ResourceBundleAttribute identity.
        /// If a records exists, that record is updated.  If no record exists one is created.
        /// </summary>
        /// <param name="rba">ResourceBundleAttribute</param>
        public void Save(ResourceBundleAttribute rba)
        {
            ResourceBundleAttribute currentRba = this.Context.ResourceBundleAttributes.FirstOrDefault(ra => ra.ResourceBundleId == rba.ResourceBundleId && ra.ResourcePlanId == rba.ResourcePlanId && (!ra.ProjectPhaseId.HasValue || ra.ProjectPhaseId == rba.ProjectPhaseId));

            if (currentRba != null)
            {
                currentRba.DateUpdated   = DateTime.Now;
                currentRba.UserUpdatedId = rba.UserCreatedId;
                currentRba.CommercialOperationEndDate   = rba.CommercialOperationEndDate;
                currentRba.CommercialOperationStartDate = rba.CommercialOperationStartDate;
                currentRba.DateEffective = rba.DateEffective;
                currentRba.DateEnd       = rba.DateEnd;
                currentRba.DateReplaced  = rba.DateReplaced;
                currentRba.DependableGenerationCapacity  = rba.DependableGenerationCapacity;
                currentRba.EffectiveLoadCarryingCapacity = rba.EffectiveLoadCarryingCapacity;
                currentRba.OriginalId = rba.OriginalId;
                currentRba.PotentialIncludeCapacity   = rba.PotentialIncludeCapacity;
                currentRba.SystemCapacity             = rba.SystemCapacity;
                currentRba.MaximumPowerOutputCapacity = rba.MaximumPowerOutputCapacity;
                currentRba.NitsDesignatedCapacity     = rba.NitsDesignatedCapacity;
                currentRba.NamePlateCapacityInMW      = rba.NamePlateCapacityInMW;
                currentRba.IsDesignated = rba.IsDesignated;
                rba.Id = currentRba.Id;
            }
            else
            {
                this.Context.ResourceBundleAttributes.InsertOnSubmit(rba);
            }
            this.Context.SubmitChanges();
        }
        public void DeleteAttribute(int resourceBundleId, int resourcePlanId, int?phaseId)
        {
            ResourceBundleAttribute resourceBundleAttribute = this.Context.ResourceBundleAttributes.FirstOrDefault(rb => rb.ResourceBundleId == resourceBundleId &&
                                                                                                                   rb.ResourcePlanId == resourcePlanId &&
                                                                                                                   rb.ProjectPhaseId == phaseId);

            if (resourceBundleAttribute == null)
            {
                return;
            }
            this.Context.ResourceBundleAttributes.DeleteOnSubmit(resourceBundleAttribute);
            this.Context.SubmitChanges();
        }