/// <summary>
        /// Delete the inflationIndex Record(s)
        /// </summary>
        /// <param name="Ids">The inflation index id list to remove</param>
        public void DeleteInflationIndex(List <int> Ids, int?userId)
        {
            foreach (var id in Ids)
            {
                if (id != 0)
                {
                    //To check weather Charging index is associated with contratmaintaince or not
                    List <ContractMaintenance> contractMaintaince = mdbDataContext.ContractMaintenances.Where(c => c.InflationIndexID == id && !c.IsDeleted).ToList();

                    if (contractMaintaince.Count <= 0)
                    {
                        ChargingIndex deleteChargingIndex = new ChargingIndex();
                        deleteChargingIndex = mdbDataContext.ChargingIndexes.FirstOrDefault(c => c.ID == id);

                        if (deleteChargingIndex != null)
                        {
                            deleteChargingIndex.IsDeleted       = true;
                            deleteChargingIndex.LastUpdatedBy   = userId;
                            deleteChargingIndex.LastUpdatedDate = DateTime.Now;

                            List <ChargingUplift> chargingUpliftList = mdbDataContext.ChargingUplifts.Where
                                                                           (c => c.IndexId == id && c.IsDeleted == false).ToList();

                            foreach (var chargingUplift in chargingUpliftList)
                            {
                                chargingUplift.IsDeleted       = true;
                                chargingUplift.LastUpdatedBy   = userId;
                                chargingUplift.LastUpdatedDate = DateTime.Now;
                            }
                        }
                    }
                }
            }
            mdbDataContext.SubmitChanges();
        }
 /// <summary>
 /// Save the Inflation index
 /// </summary>
 /// <param name="inflationIndexVO">Value Object InflationIndex</param>
 public void SaveInflationIndex(InflationIndexVO inflationIndexVO)
 {
     if (inflationIndexVO.InflationIndexId == 0)
     {
         //Insert New Record
         ChargingIndex chargingIndex = new ChargingIndex();
         chargingIndex.ChargingIndex1 = inflationIndexVO.InflationIndexName;
         chargingIndex.Description    = inflationIndexVO.Description.Trim().Replace("\r\n", "\n");
         chargingIndex.IndexUsed      = inflationIndexVO.UseIndex;
         chargingIndex.CreationDate   = DateTime.Now;
         chargingIndex.CreatedBy      = inflationIndexVO.CreatedByUserId;
         mdbDataContext.ChargingIndexes.InsertOnSubmit(chargingIndex);
         mdbDataContext.SubmitChanges();
     }
     else
     {
         //Update Existing Record
         ChargingIndex chargingIndex = mdbDataContext.ChargingIndexes.SingleOrDefault(c => c.ID == inflationIndexVO.InflationIndexId);
         chargingIndex.ChargingIndex1  = inflationIndexVO.InflationIndexName;
         chargingIndex.Description     = inflationIndexVO.Description.Trim().Replace("\r\n", "\n");
         chargingIndex.IndexUsed       = inflationIndexVO.UseIndex;
         chargingIndex.LastUpdatedDate = DateTime.Now;
         chargingIndex.LastUpdatedBy   = inflationIndexVO.LastUpdatedByUserId;
         mdbDataContext.SubmitChanges();
     }
 }
 /// <summary>
 /// Transpose LINQ object to Value object
 /// </summary>
 /// <param name="ChargingIndex">LINQ inflation index object</param>
 public InflationIndexVO(ChargingIndex inflationIndex)
 {
     InflationIndexId       = inflationIndex.ID;
     InflationIndexName     = inflationIndex.ChargingIndex1;
     Description            = inflationIndex.Description;
     UseIndex               = inflationIndex.IndexUsed;
     CreatedByUserId        = inflationIndex.CreatedBy;
     LastUpdatedByUserId    = inflationIndex.LastUpdatedBy;
     InflationIndexNameDesc = inflationIndex.Description + "-" + inflationIndex.ChargingIndex1;
 }
        /// <summary>
        /// Get Inflation index details by Id
        /// </summary>
        /// <param name="indexId">index Id</param>
        /// <returns>IndexId Details</returns>
        public InflationIndexVO GetInflationIndexById(int indexId = 0)
        {
            ChargingIndex    inflationIndex   = mdbDataContext.ChargingIndexes.SingleOrDefault(c => c.ID == indexId);
            InflationIndexVO inflationIndexVO = null;

            if (inflationIndex != null)
            {
                inflationIndexVO = new InflationIndexVO(inflationIndex);
            }
            return(inflationIndexVO);
        }
        /// <summary>
        /// Get Inflation index details name
        /// </summary>
        /// <param name="indexName">index name</param>
        /// <returns>Index details</returns>
        public InflationIndexVO GetInflationIndexByName(string indexName)
        {
            ChargingIndex chargingIndex = mdbDataContext.ChargingIndexes.Where(x => x.ChargingIndex1.Equals(indexName) && x.IsDeleted == false).SingleOrDefault();

            InflationIndexVO inflationIndexVO = null;

            if (chargingIndex != null)
            {
                inflationIndexVO = new InflationIndexVO(chargingIndex);
            }
            return(inflationIndexVO);
        }