Beispiel #1
0
        //public ElectricityPurchaseAgreement()
        //{
        //    this.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["EpicDB"].ConnectionString;
        //}

        /// <summary>
        /// Return a non-persistable clone of the EPA object
        /// </summary>
        /// <returns></returns>
        public ElectricityPurchaseAgreement Clone()
        {
            ElectricityPurchaseAgreement clone = new ElectricityPurchaseAgreement();

            clone.Code = this.Code;
            clone.NitsDesignatedCapacity = this.NitsDesignatedCapacity;
            clone.EPACapacity            = this.EPACapacity;
            clone.EPAStatusId            = this.EPAStatusId;
            clone.EstimatedInServiceDate = this.EstimatedInServiceDate;
            clone.ActualInServiceDate    = this.ActualInServiceDate;
            clone.PowerCallId            = this.PowerCallId;
            clone.OwnerName = this.OwnerName;
            return(clone);
        }
        /// <summary>
        /// Inserts a new ElectricityPurchaseAgreement object to Db or updates any existing ElectricityPurchaseAgreement objects (based on ElectricityPurchaseAgreement)
        /// </summary>
        /// <param name="epa">ElectricityPurchaseAgreement object</param>
        public int SaveEPA(ElectricityPurchaseAgreement epa)
        {
            ElectricityPurchaseAgreement currentEPA = this.Context.ElectricityPurchaseAgreements.FirstOrDefault(e => e.Code == epa.Code);
            //ElectricityPurchaseAgreement cClone = null;
            int insertedRecords = 0;

            if (currentEPA != null)
            {
                //cClone = currentEPA.Clone();
                //Log.Info("Updating EPA record for " + currentEPA.Code );
                currentEPA.DateUpdated              = epa.DateCreated;
                currentEPA.UserUpdatedId            = epa.UserCreatedId;
                currentEPA.EPACapacity              = epa.EPACapacity;
                currentEPA.MaxTakeOrPay             = epa.MaxTakeOrPay;
                currentEPA.NitsDesignatedCapacity   = epa.NitsDesignatedCapacity;
                currentEPA.ContractManager          = epa.ContractManager;          //.SafeSubstring(0,100);
                currentEPA.SecondaryContractManager = epa.SecondaryContractManager; //.SafeSubstring(0, 100);
                currentEPA.Description              = epa.Description;
                currentEPA.Code                   = epa.Code;                       //.SafeSubstring(0, 50);
                currentEPA.EPAStatusId            = epa.EPAStatusId;
                currentEPA.PowerCallId            = epa.PowerCallId;
                currentEPA.EstimatedInServiceDate = epa.EstimatedInServiceDate;
                currentEPA.ActualInServiceDate    = epa.ActualInServiceDate;
                currentEPA.OwnerName              = epa.OwnerName; //.SafeSubstring(0, 80);
                epa.Id = currentEPA.Id;
            }
            else
            {
                //Log.Info("Creating new record for "+ currentEPA.Code );
                this.Context.ElectricityPurchaseAgreements.InsertOnSubmit(epa);
                insertedRecords = 1;
            }
            this.Context.SubmitChanges();
            //this.ReportPairs.Items.Add(new Report.ReportPair(cClone, epa));
            return(insertedRecords);
        }
        /// <summary>
        /// Retrieves an EPA object based on input identity
        /// </summary>
        /// <param name="id">EPA identity</param>
        /// <returns>EPA object</returns>
        public ElectricityPurchaseAgreement GetEPA(int id)
        {
            ElectricityPurchaseAgreement myEpa = new ElectricityPurchaseAgreement();

            return(this.Context.ElectricityPurchaseAgreements.FirstOrDefault(epa => epa.Id == id));
        }
        /// <summary>
        /// Retrieve EPA Information based on code
        /// </summary>
        /// <param name="code">TLA code</param>
        public ElectricityPurchaseAgreement GetEPA(string code)
        {
            ElectricityPurchaseAgreement myEpa = new ElectricityPurchaseAgreement();

            return(this.Context.ElectricityPurchaseAgreements.FirstOrDefault(epa => epa.Code == code));
        }