public ActionResult SearchModel()
        {
            try
            {
                var orgId = LookUps.GetOrgId(User.Identity.Name);
                if (orgId == 0)
                {
                    orgId = Settings.Default.DefaultOrgId;
                }
                var model = new SearchModel()
                {
                    OrgId = orgId,
                    //  ModelData = _unitOfWork.PaidDataRepository.GetResultReport(orgId)
                    OrgLookUp        = LookUps.OrganisationById(orgId),
                    CobLookUp        = LookUps.ClassOfBusiness(),
                    TypeOfLossLookUp = LookUps.TypeOfLoss(),
                };


                // ModelData = _unitOfWork.PaidDataRepository.ExecWithStoreProcedure(
                //    "rModelViewByOrg @orgId",
                //new SqlParameter("orgId", SqlDbType.Int) { Value = orgId })

                return(View(model));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
        public ActionResult Index([DefaultValue(1)] int page, string keywords, [DefaultValue(10)] int pgsize)
        {
            try
            {
                var orgId = LookUps.GetOrgId(User.Identity.Name);
                if (orgId == 0)
                {
                    orgId = Settings.Default.DefaultOrgId;
                }

                List <InflationRate> rowsToShow;
                int totalRecords;



                if (!string.IsNullOrEmpty(keywords))
                {
                    rowsToShow   = _unitOfWork.InflationRateRepository.Get(filter: x => x.OrgID == orgId && x.Organisation.Name.ToUpper().Contains(keywords.Trim().ToUpper()), orderBy: q => q.OrderBy(x => x.ID)).Skip((page - 1) * pgsize).Take(pgsize).ToList();
                    totalRecords = _unitOfWork.InflationRateRepository.Get(filter: x => x.OrgID == orgId && x.Organisation.Name.ToUpper().Contains(keywords.Trim().ToUpper())).Count();
                }
                else
                {
                    rowsToShow   = _unitOfWork.InflationRateRepository.Get(filter: x => x.OrgID == orgId, orderBy: q => q.OrderBy(x => x.ID)).Skip((page - 1) * pgsize).Take(pgsize).ToList();
                    totalRecords = _unitOfWork.InflationRateRepository.Get(filter: x => x.OrgID == orgId, orderBy: q => q.OrderBy(x => x.ID)).Count();
                }

                var model = new InflationRateModel()
                {
                    Rows       = rowsToShow,
                    OrgId      = orgId,
                    PagingInfo = new PagingInfo
                    {
                        FirstItem    = ((page - 1) * pgsize) + 1,
                        LastItem     = page * pgsize,
                        CurrentPage  = page,
                        ItemsPerPage = pgsize,
                        TotalItems   = totalRecords
                    },
                    CurrentKeywords = keywords,
                    PageSize        = pgsize
                };
                return(View(model));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
        public ActionResult Index(int startYear, int endYear, int cob, int losstype)
        {
            try
            {
                //List<TypeOfLoss> rowsToShow;

                var orgId = LookUps.GetOrgId(User.Identity.Name);
                if (orgId == 0)
                {
                    orgId = Settings.Default.DefaultOrgId;
                }

                var growthCurveData =
                    _unitOfWork.DevFactorRepository.Get(
                        filter:
                        x => x.OrgID == orgId && x.FactorName.Equals("Growth Curve", StringComparison.CurrentCultureIgnoreCase))
                    .ToList();

                var chartCategory = growthCurveData.Select(a => a.DevPeriod.ToString()).ToList();
                var chartData     = growthCurveData.Select(x => x.FactorValue).Cast <object>().ToList();

                var chart = new DotNet.Highcharts.Highcharts("chart")
                            .InitChart(new Chart {
                    Type = ChartTypes.Areaspline
                })
                            .SetTitle(new Title {
                    Text = "Growth Curve"
                })
                            .SetXAxis(new XAxis
                {
                    Categories = chartCategory.ToArray(),
                })
                            .SetYAxis(new YAxis {
                    Title = new YAxisTitle {
                        Text = "Growth Curve Value"
                    }
                })
                            .SetTooltip(new Tooltip {
                    Formatter = "function() { return ''+ this.x +': '+ this.y +' units'; }"
                })
                            .SetCredits(new Credits {
                    Enabled = false
                })
                            .SetPlotOptions(new PlotOptions {
                    Areaspline = new PlotOptionsAreaspline {
                        FillOpacity = 0.5
                    }
                })
                            .SetSeries(new Series
                {
                    Name = "Dev Period",
                    Data = new Data(chartData.ToArray()),
                    // Color = ColorTranslator.FromHtml("#89A54E"),
                });



                var model = new InsuranceModel()
                {
                    OrgId    = orgId,
                    Cob      = cob,
                    LossType = losstype,

                    //LinkRatioData = _unitOfWork.PaidDataRepository.GetResultReport("LinkRatioView",
                    //  new SqlParameter("@orgId", SqlDbType.Int) { Value = orgId },
                    //    new SqlParameter("@cob", SqlDbType.Int) { Value = cob },
                    //    new SqlParameter("@losstype", SqlDbType.Int) { Value = losstype }),


                    ModelData = _unitOfWork.PaidDataRepository.GetResultReport("rModelView",
                                                                               orgId, cob, losstype),

                    ModelCummulativeData = _unitOfWork.PaidDataRepository.GetResultReport("rModelCummulativeView",
                                                                                          orgId, cob, losstype),

                    LinkRatioData = _unitOfWork.PaidDataRepository.GetResultReport("LinkRatioView",
                                                                                   orgId, cob, losstype),

                    DevFactor = _unitOfWork.PaidDataRepository.GetResultReport("DevFactView",
                                                                               orgId, cob, losstype),

                    CurrentRatio = _unitOfWork.PaidDataRepository.GetResultReport("CurrentRatioView",
                                                                                  orgId, cob, losstype),

                    ProjectedData = _unitOfWork.PaidDataRepository.GetResultReport("rModelProjectedView",
                                                                                   orgId, cob, losstype),

                    UnwiddingData = _unitOfWork.PaidDataRepository.GetResultReport("rModelUnwiddingView",
                                                                                   orgId, cob, losstype),

                    ProjectedAmount = _unitOfWork.PaidDataRepository.GetResultReport("ProjectedAmountView",
                                                                                     orgId, cob, losstype),

                    TypeOfLoss       = _unitOfWork.TypeOfLossRepository.GetByID(losstype),
                    ClassOfBusiness  = _unitOfWork.ClassOfBusinessRepository.GetByID(cob),
                    Organisation     = _unitOfWork.OrganisationRepository.GetByID(orgId),
                    StartYear        = startYear,
                    EndYear          = endYear,
                    GrowthCurveChart = chart
                };
                return(View(model));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }