コード例 #1
0
        /// <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();
        }
コード例 #2
0
 /// <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();
     }
 }
コード例 #3
0
 /// <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;
 }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        /// <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);
        }