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 Create(InflationRateModel model)
        {
            try
            {
                if (TypeNameExist(model.Entity.OrgID ?? 0, model.Entity.InflationYear ?? 0, model.Entity.ID))
                {
                    ModelState.AddModelError("", "Inflation Rate Already Exist");
                }



                if (ModelState.IsValid)
                {
                    var certGrade = model.Entity;
                    certGrade.ModifiedBy   = User.Identity.Name;
                    certGrade.ModifiedDate = DateTime.Now;
                    certGrade.CreatedBy    = User.Identity.Name;
                    certGrade.CreatedDate  = DateTime.Now;

                    _unitOfWork.InflationRateRepository.Insert(certGrade);
                    _unitOfWork.Save();
                    TempData["message"] = "<b>" + certGrade.InflationYear + "</b> was successfully created";
                    return(RedirectToAction("Index", new { orgId = model.Entity.OrgID }));
                }
                model.OrgLookUp = LookUps.OrganisationById(model.Entity.OrgID ?? 0);
                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" }));
            }
        }
Exemple #3
0
 public void LookUpsTest()
 {
     LookUps lookUps = new LookUps();
     lookUps.SetupTest();
     lookUps.TheLookUpsTest();
     lookUps.TeardownTest();
 }
        public ActionResult Edit(OutstandingDataModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var certGrade = model.Entity;
                    certGrade.ModifiedBy   = User.Identity.Name;
                    certGrade.ModifiedDate = DateTime.Now;
                    certGrade.LossYear     = certGrade.DateOfLoss.GetValueOrDefault().Year;

                    _unitOfWork.OutstandingDataRepository.Update(certGrade);
                    _unitOfWork.Save();
                    TempData["message"] = "<b>" + certGrade.ClaimNo + "</b> was successfully updated";
                    return(RedirectToAction("Index", new { orgId = model.Entity.ID }));
                }
                model.OrgLookUp        = LookUps.OrganisationById(model.Entity.OrgID ?? 0);
                model.CobLookUp        = LookUps.ClassOfBusiness();
                model.TypeOfLossLookUp = LookUps.TypeOfLoss();
                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 Edit(int id = 0)
 {
     try
     {
         var certGrade = _unitOfWork.InflationRateRepository.GetByID(id);
         if (certGrade == null)
         {
             return(HttpNotFound());
         }
         var model = new InflationRateModel
         {
             Entity    = certGrade,
             OrgLookUp = LookUps.OrganisationById(certGrade.OrgID ?? 0),
             OrgId     = certGrade.OrgID ?? 0
         };
         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 Create(int orgId)
        {
            var model = new OrgClassOfBusinessModel();

            model.OrgId       = orgId;
            model.CobLookUp   = LookUps.ClassOfBusiness();
            model.SelectedCob = unitOfWork.OrgClassOfBusinessRepository.Get(filter: x => x.OrgID == orgId).Select(x => x.BusinessClass).ToArray();
            return(View(model));
        }
        public ActionResult Create(int orgId)
        {
            var model = new InflationRateModel
            {
                Entity    = new InflationRate(),
                OrgLookUp = LookUps.OrganisationById(orgId),
                OrgId     = orgId
            };

            return(View(model));
        }
        public ActionResult Create(int orgId)
        {
            var model = new EarnedPremiumModel
            {
                Entity    = new EarnedPremium(),
                OrgLookUp = LookUps.OrganisationById(orgId),
                CobLookUp = LookUps.ClassOfBusiness(),
                OrgId     = orgId
            };

            return(View(model));
        }
        public ActionResult Create(int orgId)
        {
            var model = new PaidDataModel
            {
                Entity           = new PaidData(),
                OrgLookUp        = LookUps.OrganisationById(orgId),
                CobLookUp        = LookUps.ClassOfBusiness(),
                TypeOfLossLookUp = LookUps.TypeOfLoss(),
                OrgId            = orgId
            };

            return(View(model));
        }
        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 Create(TypeOfLossThresholdModel model)
        {
            try
            {
                if (model.Entity.MaxValue <= model.Entity.MinValue)
                {
                    ModelState.AddModelError("", "Please Make Sure Maximum Value is Higher than the Minimum Value");
                }

                if (ThresholdExist(model.Entity.OrgID ?? 0, model.Entity.ClassOfBusiness ?? 0, model.Entity.TypeOfLoss ?? 0, model.Entity.ID))
                {
                    ModelState.AddModelError("", "Threshold Already Exist");
                }

                if (ValuesConflict(model.Entity.OrgID ?? 0, model.Entity.ClassOfBusiness ?? 0, model.Entity.MinValue ?? 0, model.Entity.MaxValue ?? 0, model.Entity.ID))
                {
                    ModelState.AddModelError("", "Minimum and Maximum Values Conflict with existing setup for the selected Class of Business");
                }

                if (ModelState.IsValid)
                {
                    var certGrade = model.Entity;
                    certGrade.ModifiedBy   = User.Identity.Name;
                    certGrade.ModifiedDate = DateTime.Now;
                    certGrade.CreatedBy    = User.Identity.Name;
                    certGrade.CreatedDate  = DateTime.Now;



                    _unitOfWork.TypeOfLossThresholdRepository.Insert(certGrade);
                    _unitOfWork.Save();
                    TempData["message"] = "Type of Loss Threshold was successfully created";
                    return(RedirectToAction("Index", new { orgid = model.Entity.OrgID }));
                }

                model.OrgId            = model.Entity.OrgID ?? 0;
                model.OrgLookUp        = LookUps.OrganisationById(model.Entity.OrgID ?? 0);
                model.CobLookUp        = LookUps.ClassOfBusiness();
                model.TypeOfLossLookUp = LookUps.TypeOfLoss();
                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 CreateExcel(ExcelUploadModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var excelReader = new PaidDataExcelReader();
                    //upload excel file
                    var result = excelReader.UploadCpExcelFile(model.ExcelFile);
                    if (result.Key)
                    {
                        //if upload is successfull insert the record into the  the cpuploads

                        //if insert in ok process the excel file details
                        var processResult = excelReader.ProcessExcel(result.Value, model.OrgId, User.Identity.Name);
                        var sucessResult  = "";
                        if (processResult.Key)
                        {
                            sucessResult = processResult.Value;
                        }
                        else
                        {
                            TempData["ExcelSummary"] = processResult.Value;
                            return(RedirectToAction("Index", new { orgid = model.OrgId }));
                        }


                        TempData["ExcelSummary"] = sucessResult;
                        return(RedirectToAction("Index", new { orgid = model.OrgId }));
                    }
                    else
                    {
                        TempData["ExcelSummary"] = result.Value;
                        return(RedirectToAction("Index", new { orgid = model.OrgId }));
                    }
                }

                model.OrgLookUp = LookUps.OrganisationById(model.OrgId);
                return(View(model));
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index"));
            }
        }
 public ActionResult CreateExcel(int orgId)
 {
     try
     {
         var model = new ExcelUploadModel {
             OrgId = orgId, OrgLookUp = LookUps.OrganisationById(orgId)
         };
         return(View(model));
     }
     catch (Exception ex)
     {
         // Log with Elmah
         Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
         TempData["message"] = Settings.Default.GenericExceptionMessage;
         return(RedirectToAction("Index"));
     }
 }
        public ActionResult Create(PaidDataModel model)
        {
            try
            {
                if (ClaimExist(model.Entity.OrgID ?? 0, model.Entity.ClaimNo, model.Entity.ID))
                {
                    ModelState.AddModelError("", "Claim Number Already Exist");
                }

                if (ModelState.IsValid)
                {
                    var certGrade = model.Entity;
                    certGrade.ModifiedBy   = User.Identity.Name;
                    certGrade.ModifiedDate = DateTime.Now;
                    certGrade.CreatedBy    = User.Identity.Name;
                    certGrade.CreatedDate  = DateTime.Now;

                    //calcualte dev period
                    certGrade.LossYear  = certGrade.DateOfLoss.GetValueOrDefault().Year;
                    certGrade.PaidYear  = certGrade.DateOfPayment.GetValueOrDefault().Year;
                    certGrade.DevPeriod = certGrade.PaidYear - certGrade.LossYear;

                    _unitOfWork.PaidDataRepository.Insert(certGrade);
                    _unitOfWork.Save();
                    TempData["message"] = "<b>" + certGrade.ClaimNo + "</b> was successfully created";
                    return(RedirectToAction("Index", new { orgid = model.Entity.OrgID }));
                }
                model.OrgLookUp        = LookUps.OrganisationById(model.Entity.OrgID ?? 0);
                model.CobLookUp        = LookUps.ClassOfBusiness();
                model.TypeOfLossLookUp = LookUps.TypeOfLoss();
                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" }));
            }
        }
 //Task<TEntity> GetByIdAsync(string id );
 public Task <int> AddAsync(LookUps entity)
 {
     throw new NotImplementedException();
 }
        public ActionResult SearchModel(SearchModel model)
        {
            try
            {
                if (model.EndYear <= model.StartYear)
                {
                    ModelState.AddModelError("", "Please Make End Date is Higher than Start Date");
                }
                if (ModelState.IsValid)
                {
                    //       _unitOfWork.PaidDataRepository.UpdateHierarchy("rModelCummulativeSetUp @orgId, @startYear, @endYear,@cob,@losstype",
                    //      new SqlParameter("orgId", SqlDbType.Int) { Value = model.OrgId },
                    //      new SqlParameter("startYear", SqlDbType.Int) { Value = model.StartYear },
                    //      new SqlParameter("endYear", SqlDbType.Int) { Value = model.EndYear },
                    //        new SqlParameter("cob", SqlDbType.Int) { Value = model.ClassOfBusiness },
                    //          new SqlParameter("losstype", SqlDbType.Int) { Value = model.LossType });



                    _unitOfWork.PaidDataRepository.UpdateHierarchy("GeneralSetUp @orgId, @startYear, @endYear,@cob,@losstype",
                                                                   new SqlParameter("orgId", SqlDbType.Int)
                    {
                        Value = model.OrgId
                    },
                                                                   new SqlParameter("startYear", SqlDbType.Int)
                    {
                        Value = model.StartYear
                    },
                                                                   new SqlParameter("endYear", SqlDbType.Int)
                    {
                        Value = model.EndYear
                    },
                                                                   new SqlParameter("cob", SqlDbType.Int)
                    {
                        Value = model.ClassOfBusiness
                    },
                                                                   new SqlParameter("losstype", SqlDbType.Int)
                    {
                        Value = model.LossType
                    });

                    return(RedirectToAction("Index", new { orgid = model.OrgId, startYear = model.StartYear, endYear = model.EndYear, cob = model.ClassOfBusiness, losstype = model.LossType }));
                }



                // ModelData = _unitOfWork.PaidDataRepository.ExecWithStoreProcedure(
                //    "rModelViewByOrg @orgId",
                //new SqlParameter("orgId", SqlDbType.Int) { Value = orgId })
                model.OrgLookUp        = LookUps.OrganisationById(model.OrgId);
                model.CobLookUp        = LookUps.ClassOfBusiness();
                model.TypeOfLossLookUp = LookUps.TypeOfLoss();
                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(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" }));
            }
        }
 public Task <bool> UpdateAsync(LookUps entity)
 {
     throw new NotImplementedException();
 }