コード例 #1
0
ファイル: PolicyService.cs プロジェクト: bhaskar2583/idoc
        public bool AddPolicy(PolicyModel policy)
        {
            var entity = new Policie()
            {
                PolicyNumber     = policy.PolicyNumber,
                CarId            = policy.CarId,
                EffectiveDate    = (DateTime)policy.EffectiveDate,
                EndDate          = (DateTime)policy?.EndDate,
                IsGroupInsurance = policy.IsGroupInsurance,
                IsActive         = true,
                AddUser          = LoginUserDetails.GetWindowsLoginUserName(),
                AddDate          = DateUtil.GetCurrentDate(),
                CoverageId       = policy.CoverageId,
                ProductId        = policy.ProductId
            };

            _policyRepository.Add(entity);

            var latestPolicy = _policyRepository.GetAll().OrderByDescending(p => p.Id).FirstOrDefault();

            if (latestPolicy != null)
            {
                var clientPolocieModel = new ClientPolicie()
                {
                    ClientId  = policy.ClientId,
                    PolicieId = latestPolicy.Id,
                    IsActive  = true,
                    AddUser   = LoginUserDetails.GetWindowsLoginUserName(),
                    AddDate   = DateUtil.GetCurrentDate()
                };
                _commonService.AddClientPolocie(clientPolocieModel);
            }

            return(true);
        }
コード例 #2
0
        public List <PolicyDto> Get()
        {
            List <PolicyEntity> listPolicyEntities;

            try {
                var     config  = new MapperConfiguration(cfg => cfg.CreateMap <PolicyEntity, PolicyDto>().ReverseMap());
                IMapper iMapper = config.CreateMapper();

                listPolicyEntities = policyRepository.GetAll();

                List <PolicyDto> listPolicyDtos = iMapper.Map <List <PolicyEntity>, List <PolicyDto> >(listPolicyEntities);
                return(listPolicyDtos);

                #region Exceptions With Log
            } catch (NotSupportedException e) {
                log.Error(Resource_Application_Services.NotSuportedError
                          + e.Message + Resource_Application_Services.ErrorLogSeparation
                          + e.Data + Resource_Application_Services.ErrorLogSeparation
                          + e.StackTrace);
                throw new VuelingException(Resource_Application_Services.NotSuportedError, e);
            } catch (ObjectDisposedException e) {
                log.Error(Resource_Application_Services.ObjectDisposedError
                          + e.Message + Resource_Application_Services.ErrorLogSeparation
                          + e.Data + Resource_Application_Services.ErrorLogSeparation
                          + e.StackTrace);
                throw new VuelingException(Resource_Application_Services.ObjectDisposedError, e);
            } catch (InvalidOperationException e) {
                log.Error(Resource_Application_Services.InvalidOperationError
                          + e.Message + Resource_Application_Services.ErrorLogSeparation
                          + e.Data + Resource_Application_Services.ErrorLogSeparation
                          + e.StackTrace);
                throw new VuelingException(Resource_Application_Services.InvalidOperationError, e);
            }
            #endregion
        }
コード例 #3
0
        public ResponseEntityVM GetAll()
        {
            try
            {
                var coverateTypeCodes = ((List <CodeVM>)_codeService.GetCoverageTypeCodes().Result).ToList();
                var riskTypeCodes     = ((List <CodeVM>)_codeService.GetRiskTypeCodes().Result).ToList();

                var policyList = _repository.GetAll().Select(x => new PolicyVM()
                {
                    PolicyID           = x.PolicyID,
                    Name               = x.Name,
                    Description        = x.Description,
                    CoveragePercentage = x.CoveragePercentage,
                    CoverageType       = coverateTypeCodes.Where(y => y.CodeID.Equals(x.CoverageTypeID)).FirstOrDefault().Code,
                    RiskType           = riskTypeCodes.Where(y => y.CodeID.Equals(x.RiskTypeID)).FirstOrDefault().Code,
                    Price              = x.Price,
                    CoverageTerm       = x.CoverageTerm
                });

                return(new ResponseEntityVM()
                {
                    StatusCode = System.Net.HttpStatusCode.OK, Result = policyList.ToList()
                });
            }
            catch (Exception ex)
            {
                return(new ResponseEntityVM()
                {
                    StatusCode = System.Net.HttpStatusCode.InternalServerError, Message = $"There was an error getting the Policies: {ex.Message}"
                });
            }
        }
コード例 #4
0
        public ActionResult ListData(int pageIndex, int pageSize)
        {
            var model    = policyRepository.GetAll();
            var totalAdv = model.Count();

            model = model.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            return(Json(new
            {
                viewContent = RenderViewToString("~/Areas/Admin/Views/Policy/_ListData.cshtml", model),
                totalPages = Math.Ceiling(((double)totalAdv / pageSize)),
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
        public async Task <ICollection <string> > Execute()
        {
            var policies = await _repositoryExceptionHelper.HandleException(
                ErrorDescriptions.TheAuthorizationPolicyCannotBeRetrieved,
                () => _policyRepository.GetAll());

            if (policies == null ||
                !policies.Any())
            {
                return(new List <string>());
            }

            return(policies.Select(p => p.Id).ToList());
        }
コード例 #6
0
        public PolicyDTO[] GetPoliciesByClientId(Guid id)
        {
            var policies = _policyRepository.GetAll().Where(x => x.ClientId == id);

            return(policies.Select(x => new PolicyDTO()
            {
                ID = x.ID,
                AmountInsured = x.AmountInsured,
                InceptionDate = x.InceptionDate,
                InstallmentPayment = x.InstallmentPayment,
                Email = x.Email,
                ClientID = x.ClientId
            })
                   .ToArray());
        }
コード例 #7
0
ファイル: ClientService.cs プロジェクト: coloseis/Gentil
        public PolicyDTO[] GetPoliciesByClientName(string name)
        {
            var client = _clientRepository.GetAll().SingleOrDefault(x => x.Name == name);

            if (client == null)
            {
                return(null);
            }

            var policies = _policyRepository.GetAll().Where(x => x.ClientId == client.ID);

            return(policies.Select(x => new PolicyDTO()
            {
                ID = x.ID,
                AmountInsured = x.AmountInsured,
                InceptionDate = x.InceptionDate,
                InstallmentPayment = x.InstallmentPayment,
                Email = x.Email,
                ClientID = x.ClientId
            })
                   .ToArray());
        }
コード例 #8
0
ファイル: PolicyFacadeService.cs プロジェクト: mehabadi/HPMS
 public List <PolicyDTOWithActions> GetAllPolicies()
 {
     return(policyRep.GetAll().Select(r => policyWithActionMapper.MapToModel(r)).ToList());
 }
コード例 #9
0
 public async Task <IEnumerable <Policy> > GetAll()
 {
     return(await _policyRepository.GetAll());
 }
コード例 #10
0
        public void GetTest()
        {
            List <PolicyEntity> listPolicyEntities = policyRepository.GetAll();

            Assert.IsTrue(listPolicyEntities.Count() == 193);
        }
コード例 #11
0
 /// <summary>
 /// The GetAll.
 /// </summary>
 /// <returns>The <see cref="IEnumerable{Policy}"/>.</returns>
 public IEnumerable <Policy> GetAll()
 {
     return(_policyRepository.GetAll());
 }
コード例 #12
0
        // GET: About
        public PartialViewResult LoadPolicy()
        {
            var policie = policyRepository.GetAll().ToList();

            return(PartialView(policie));
        }
コード例 #13
0
 public Policie GetPolicyByNoCarriageCoverage(string policyNo, int carrierId, int coverageId)
 {
     return(_policyRepository.GetAll().
            Where(pc => pc.PolicyNumber == policyNo && pc.CarId == carrierId && pc.CoverageId == coverageId).FirstOrDefault());
 }