/// <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>
        /// Gets the List of Recalculation requests
        /// </summary>
        /// <returns>Recalculation Request List</returns>
        public List <RecalculationVO> GetRecalculationRequestList()
        {
            InflationIndexVO       inflationIndexVO    = new InflationIndexVO();
            List <RecalculationVO> recalculationVOList = new List <RecalculationVO>();
            List <Recalculation>   recalculationList   = mdbDataContext.Recalculations.Where(c => c.IsDeleted == false).OrderByDescending(c => c.Date).ToList();


            foreach (var item in recalculationList)
            {
                string indexNames = string.Empty;
                if (item.IndexIds != "0")
                {
                    int length = item.IndexIds.Split(';').Count();
                    for (int i = 0; i < length; i++)
                    {
                        var id = System.Convert.ToInt32(item.IndexIds.Split(';')[i]);
                        inflationIndexVO = GetInflationIndexById(id);
                        indexNames      += inflationIndexVO.InflationIndexName + ",";
                        //item.IndexIds += inflationIndexVO.InflationIndexName + ",";
                    }
                    item.IndexIds = string.Empty;
                    item.IndexIds = indexNames.Remove(indexNames.Length - 1);
                }

                recalculationVOList.Add(new RecalculationVO(item));
            }

            //foreach (var item in recalculationList)
            //{
            //    recalculationVOList.Add(new RecalculationVO(item));
            //}


            return(recalculationVOList);
        }
示例#3
0
        /// <summary>
        /// Save inflation index details
        /// </summary>
        /// <param name="model">model Object</param>
        public ActionResult InflationIndexSave(MODEL.InflationIndex model)
        {
            try
            {
                bool ismodelValid = ModelState.IsValid;
                if (!ismodelValid)
                {
                    ismodelValid = IsModelValidForMultilineTextbox("Description", model.Description, 30);
                }

                if (ismodelValid)
                {
                    //Get user id
                    int?userId = Session.GetUserId();
                    InflationIndexService inflationIndexService = new InflationIndexService();
                    //InflationIndexVO inflationIndexVO = new InflationIndexVO(model, userId);

                    InflationIndexVO inflationIndexVO = model.Transpose(userId);

                    inflationIndexService.SaveInflationIndex(inflationIndexVO);
                    return(new HttpStatusCodeResult(200));
                }
                else
                {
                    throw new ApplicationException(String.Format(Constants.CANNOT_SAVE, Constants.INDEX));
                }
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
示例#4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="InflationIndexVO">InflationIndexVO model object</param>
 public InflationIndex(InflationIndexVO inflationIndexVO)
 {
     ID = inflationIndexVO.InflationIndexId;
     InflationIndexId       = inflationIndexVO.InflationIndexId;
     IndexName              = inflationIndexVO.InflationIndexName;
     Description            = inflationIndexVO.Description;
     UseIndex               = inflationIndexVO.UseIndex;
     InflationIndexNameDesc = inflationIndexVO.Description + "-" + inflationIndexVO.InflationIndexName;
 }
        /// <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);
        }
示例#7
0
        /// <summary>
        /// Save the Inflation index
        /// </summary>
        /// <param name="inflationIndexVO">Value Object InflationIndex</param>
        public void SaveInflationIndex(InflationIndexVO inflationIndexVO)
        {
            //Get and check whether index already exist with same name or not
            InflationIndexVO inflationIndexExist = inflationIndexDAL.GetInflationIndexByName(inflationIndexVO.InflationIndexName);

            if (inflationIndexExist != null && inflationIndexVO.InflationIndexId != inflationIndexExist.InflationIndexId)
            {
                throw new ApplicationException(Constants.INDEX_ALREADY_EXIST);
            }
            else
            {
                inflationIndexDAL.SaveInflationIndex(inflationIndexVO);
            }
        }
示例#8
0
        /// <summary>
        /// Transpose Model object to Value Object
        /// </summary>
        /// <param name="userId">user Id</param>
        /// <returns>Value object</returns>
        public InflationIndexVO Transpose(int?userId)
        {
            InflationIndexVO inflationIndexVO = new InflationIndexVO();

            inflationIndexVO.InflationIndexId       = this.ID;
            inflationIndexVO.InflationIndexName     = this.IndexName;
            inflationIndexVO.Description            = this.Description;
            inflationIndexVO.UseIndex               = this.UseIndex;
            inflationIndexVO.InflationIndexNameDesc = this.Description + "-" + this.IndexName;
            inflationIndexVO.CreatedByUserId        = userId;
            inflationIndexVO.LastUpdatedByUserId    = userId;

            return(inflationIndexVO);
        }
示例#9
0
        /// <summary>
        /// Edit inflation index
        /// </summary>
        /// <param name="id">Inflation Index Id</param>
        /// <returns>The Inflation Index Details view</returns>
        public ActionResult InflationIndexEdit(int id)
        {
            MODEL.InflationIndex inflationIndex = null;
            try
            {
                InflationIndexService inflationIndexService = new InflationIndexService();

                //Get index details
                InflationIndexVO inflationIndexVO = inflationIndexService.GetInflationIndexById(id);
                if (inflationIndexVO == null)
                {
                    ModelState.AddModelError("", String.Format(Constants.ITEM_NOT_FOUND, Constants.INDEX));
                }
                else
                {
                    inflationIndex = new MODEL.InflationIndex(inflationIndexVO);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(PartialView("InflationIndexDetails", inflationIndex));
        }