Esempio n. 1
0
        /// <summary>
        /// Gets inflation index rates list by inflation index Id
        /// </summary>
        /// <param name="param">The params</param>
        /// <param name="inflationIndexId">Inflation Index Id</param>
        /// <returns>inflation index rate list</returns>
        public ActionResult GetInflationIndexRateListById(MODEL.jQueryDataTableParamModel param, int inflationIndexId)
        {
            try
            {
                InflationIndexRateService   inflationIndexRateService = new InflationIndexRateService();
                List <InflationIndexRateVO> inflationIndexRateVOList  = inflationIndexRateService.GetInflationIndexRateListById(inflationIndexId);

                List <MODEL.InflationIndexRate> inflationIndexRateList = new List <MODEL.InflationIndexRate>();
                if (inflationIndexRateVOList != null)
                {
                    foreach (InflationIndexRateVO inflationIndexRateVO in inflationIndexRateVOList)
                    {
                        inflationIndexRateList.Add(new MODEL.InflationIndexRate(inflationIndexRateVO));
                    }
                }

                //get the field on with sorting needs to happen and set the
                //ordering function/delegate accordingly.
                int sortColumnIndex  = Convert.ToInt32(Request["iSortCol_0"]);
                var orderingFunction = GetInflationIndexRateOrderingFunction(sortColumnIndex);

                var result = GetFilteredObjects(param, inflationIndexRateList, orderingFunction);
                return(result);
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Save the Inflation index rate
        /// </summary>
        /// <param name="model">The InflationIndexRate model</param>
        public ActionResult InflationIndexRateSave(MODEL.InflationIndexRate model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //Get user id
                    int?userId = Session.GetUserId();

                    InflationIndexRateService inflationIndexRateService = new InflationIndexRateService();
                    //InflationIndexRateVO inflationIndexRateVO = new InflationIndexRateVO(model, userId);

                    InflationIndexRateVO inflationIndexRateVO = model.Transpose(userId);

                    inflationIndexRateService.SaveInflationIndexRate(inflationIndexRateVO);
                    return(new HttpStatusCodeResult(200));
                }
                else
                {
                    foreach (var item in ModelState)
                    {
                        if (item.Key == "chargingUpliftDate" && item.Value.Errors.Count > 0)
                        {
                            return(new HttpStatusCodeAndErrorResult(500, Constants.INVALID_DATE));
                        }
                    }
                    throw new ApplicationException(String.Format(Constants.CANNOT_SAVE, Constants.INDEXRATE));
                }
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Delete inflation index rate(s)
        /// </summary>
        /// <param name="Ids">Ids of inflation index rate to be deleted</param>
        public ActionResult InflationIndexRateDelete(List <int> Ids)
        {
            try
            {
                //Get user id
                int?userId = Session.GetUserId();

                InflationIndexRateService inflationIndexRateService = new InflationIndexRateService();
                inflationIndexRateService.DeleteInflationIndexRate(Ids, userId);

                return(new HttpStatusCodeResult(200));
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Get Details of inflation index rate by Id
        /// </summary>
        /// <param name="id">Index Rate Id</param>
        /// <returns>The inflation index rate details view</returns>
        public ActionResult InflationIndexRateEdit(int id)
        {
            MODEL.InflationIndexRate inflationIndexRate = null;
            try
            {
                InflationIndexRateService inflationIndexRateService = new InflationIndexRateService();

                //Get inflation index rate
                InflationIndexRateVO inflationIndexRateVO = inflationIndexRateService.GetInflationIndexRateById(id);
                if (inflationIndexRateVO == null)
                {
                    ModelState.AddModelError("", String.Format(Constants.ITEM_NOT_FOUND, Constants.INDEXRATE));
                }
                else
                {
                    inflationIndexRate = new InflationIndexRate(inflationIndexRateVO);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(PartialView("InflationIndexRateDetails", inflationIndexRate));
        }