Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public PolicyModel GetById(int Id)
        {
            var entity = _policyRepository.GetById(Id);

            if (entity != null)
            {
                var policy = new PolicyModel()
                {
                    Id               = entity.Id,
                    IsActive         = (bool)entity.IsActive,
                    PolicyNumber     = entity.PolicyNumber,
                    CarId            = entity.CarId,
                    CoverageId       = entity.CoverageId,
                    ProductId        = entity.ProductId,
                    EffectiveDate    = entity.EffectiveDate,
                    EndDate          = entity.EndDate,
                    IsGroupInsurance = (bool)entity.IsGroupInsurance,
                    AddUser          = entity.AddUser,
                    AddDate          = entity.AddDate,
                    RevUser          = entity.RevUser,
                    RevDate          = entity.RevDate
                };

                var carrier  = _carrierService.GetById(policy.CarId);
                var coverage = _commonService.GetCoverageById(policy.CoverageId);
                var product  = _commonService.GetProductById(policy.ProductId);
                MapSelectedCarrier(policy, carrier);
                MapSelectedProduct(policy, product);
                MapSelectedCoverage(policy, coverage);
                return(policy);
            }

            return(null);
        }
Esempio n. 3
0
        public Task <Unit> Handle(AddPolicyRequest request, CancellationToken cancellationToken)
        {
            PolicyModel policy = _mapper.Map <PolicyModel>(request);

            _policyService.AddPolicy(policy);
            return(Task.FromResult(Unit.Value));
        }
Esempio n. 4
0
        public ActionResult AddPolicy(PolicyModel policy)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = _policyService.AddPolicy(policy);

                    if (result)
                    {
                        ViewBag.Message = "Policy details added successfully";
                    }
                }
                _policyService.MapCarriers(policy);
                _policyService.MapCoverages(policy);
                _policyService.MapClients(policy);
                _policyService.MapProductsOfCoverage(policy, policy.CoverageId);
                return(View(policy));
            }
            catch (Exception ex)
            {
                _policyService.MapCarriers(policy);
                _policyService.MapCoverages(policy);
                _policyService.MapProductsOfCoverage(policy, policy.CoverageId);
                ViewBag.Message = "Error while adding policy details";
                return(View(policy));
            }
        }
        public ActionResult EditPolicy(int id)
        {
            SqlConnection con = new SqlConnection(constring);
            string        q   = "SELECT * from Policy where policy_id=@policy_id";

            con.Open();
            SqlCommand cmd = new SqlCommand(q, con);

            cmd.Parameters.AddWithValue("@policy_id", id);

            cmd.ExecuteNonQuery();

            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataTable      dt      = new DataTable();

            adapter.Fill(dt);
            PolicyModel ob = new PolicyModel();

            if (dt.Rows.Count == 1)
            {
                ob.policy_id  = Convert.ToInt32(dt.Rows[0][0].ToString());
                ob.policyHead = dt.Rows[0][1].ToString();

                ob.policies = dt.Rows[0][2].ToString();
            }

            return(View(ob));
        }
Esempio n. 6
0
        public List <ActiveCoverViewModel> GetActiveCoverTileModels(Action <object> OnClick)
        {
            if (_MasterRepo.DataSource.PolicyList != null && _MasterRepo.DataSource.PurchaseHistory != null)
            {
                var productCover = from policy in _MasterRepo.DataSource.PurchaseHistory
                                   group policy.Cover by policy.Product into Transaction
                                   select new {
                    Product     = Transaction.Key,
                    CoverAmount = Transaction.Sum()
                };
                var ProductStartDate = from policy in _MasterRepo.DataSource.PurchaseHistory
                                       group policy.StartDate by policy.Product into Transaction
                                       select new { product = Transaction.Key, StartDate = Transaction.Min() };
                var ProductEndDate = from policy in _MasterRepo.DataSource.PurchaseHistory
                                     group policy.EndDate by policy.Product into Transaction
                                     select new { product = Transaction.Key, EndDate = Transaction.Max() };
                var product = new PolicyModel
                {
                    name          = productCover.FirstOrDefault().Product,
                    ensuredAmount = productCover.FirstOrDefault().CoverAmount,
                    startDate     = ProductStartDate.FirstOrDefault().StartDate,
                    endDate       = ProductEndDate.FirstOrDefault().EndDate
                };



                List <ActiveCoverViewModel> list = new List <ActiveCoverViewModel>();
                list.Add(GetActiveCoverTileModelFromPolicy(product, OnClick, 1));

                return(list);
            }
            return(null);
        }
        public ResponseEntityVM Create(PolicyModel entity)
        {
            try
            {
                var highRiskType               = RiskTypeEnum.High.ToString("G");
                var highRiskTypeCode           = ((List <CodeVM>)_codeService.GetRiskTypeCodes().Result).Where(x => x.Code.Equals(highRiskType)).FirstOrDefault();
                var validateBusinessRuleResult = ValidateBusinessRule(entity, highRiskTypeCode);

                if (validateBusinessRuleResult.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var activeAssignmentStatus = AssigmentStatusEnum.Assigned.ToString("G");

                    var activeAssignmentStatusCode = ((List <CodeVM>)_codeService.GetAssignmentStatusCodes().Result).Where(x => x.Code.Equals(activeAssignmentStatus)).FirstOrDefault();

                    entity.PolicyStatusID = activeAssignmentStatusCode.CodeID;
                    var entityResult = _repository.Insert(entity);
                    _repository.SaveChanges();
                    return(new ResponseEntityVM()
                    {
                        StatusCode = System.Net.HttpStatusCode.Created, Result = entityResult
                    });
                }
                return(validateBusinessRuleResult);
            }
            catch (Exception ex)
            {
                return(new ResponseEntityVM()
                {
                    StatusCode = System.Net.HttpStatusCode.InternalServerError, Message = $"There was an error creating the policy: {ex.Message}"
                });
            }
        }
Esempio n. 8
0
        public ActionResult Edit(int id, PolicyModel model)
        {
            try
            {
                if (ModelState.IsValid == false)
                {
                    PolicyDetailModel policyDetailModel = GetPolicyDetailModel(id);
                    return(View(policyDetailModel));
                }

                model.StatusId = AttributeProviderSvc.GetPolicyStatusIdFromName(model.StatusName);

                var entity = AutoMapper.Mapper.Map <Policy>(model);
                Uow.Policies.Update(entity);
                Uow.SaveChanges();

                if (string.IsNullOrEmpty(model.ReturnUrl) == false)
                {
                    return(Redirect(model.ReturnUrl));
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                PolicyDetailModel policyDetailModel = GetPolicyDetailModel(id);
                return(View(policyDetailModel));
            }
        }
Esempio n. 9
0
        public ActionResult RenewPolicy(PolicyModel model)
        {
            try
            {
                var origEntity = Uow.Policies.GetById(model.Id);
                var entity     = AutoMapper.Mapper.Map <Policy>(model);

                entity.Id = 0;
                entity.RenewalPolicyNumber = origEntity.PolicyNumber;
                entity.DateIssued          = DateTime.Now;

                entity.StatusId     = AttributeProviderSvc.GetPolicyStatusIdFromName("active");
                origEntity.StatusId = AttributeProviderSvc.GetPolicyStatusIdFromName("expired");

                Uow.Policies.Add(entity);
                Uow.Policies.Update(origEntity);
                Uow.SaveChanges();

                return(RedirectToAction("Details", new { id = entity.Id }));
            }
            catch (Exception ex)
            {
                LoggingSvc.LogError(ex);
                return(RedirectToAction("Details", new { id = model.Id }));
            }
        }
Esempio n. 10
0
        public JsonResult AddPoliciesToClient(String idsPolice, String clientId)
        {
            if (!idsPolice.Equals(String.Empty) && !clientId.Equals(String.Empty))
            {
                int id = 0;
                //Get Client
                HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Client/" + clientId.ToString()).Result;
                ClientModel         eClient  = response.Content.ReadAsAsync <ClientModel>().Result;
                foreach (String item in idsPolice.Split('|'))
                {
                    if (int.TryParse(item, out id))
                    {
                        response = GlobalVariables.WebApiClient.GetAsync("Policy/" + id.ToString()).Result;
                        PolicyModel ePolicy = response.Content.ReadAsAsync <PolicyModel>().Result;
                        if (ePolicy != null)
                        {
                            ClientPolicyBaseModel cp = new ClientPolicyBaseModel()
                            {
                                clientid = eClient.id, policyid = ePolicy.id
                            };
                            response = GlobalVariables.WebApiClient.PostAsJsonAsync("ClientPolicy", cp).Result;
                        }
                    }
                }

                TempData["ClientMessage"] = "Client created successsfully";
            }
            return(Json(new { isValid = true }, JsonRequestBehavior.AllowGet));
        }
        public void Setup()
        {
            _policyModel   = new PolicyModel();
            _responseModel = new ResponseModel();

            _policyReceiver = new PolicyReceiver();
        }
Esempio n. 12
0
        private static async Task <ContentDocument> GetScrubbedContentRecursive(
            Uri requestUrl,
            PolicyModel policy,
            int maxRecursion)
        {
            var urls    = new List <Uri>(new[] { requestUrl });
            var content = await GetScrubbedContent(requestUrl, policy);

            while (--maxRecursion > 0 && content.IsNextUrl)
            {
                var nextUrl = ComputeAbsoluteNextUrl(
                    content.NextUrl,
                    urls.Last());

                if (!urls.Contains(nextUrl))
                {
                    var subContent = await GetScrubbedContent(nextUrl, policy);

                    urls.Add(nextUrl);
                    content = content.Merge(subContent);
                }
                else
                {
                    return(content);
                }
            }

            return(content);
        }
Esempio n. 13
0
        public ActionResult Create()
        {
            PolicyModel model = new PolicyModel();

            model.Actived = true;
            return(View(model));
        }
Esempio n. 14
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     loginName = ViewState["loginName"].ToString();
     policy    = bll.GetModel(int.Parse(policyId.Value.ToString()));
     policy.Chineseintroduced   = txtChina.Text.Trim();
     policy.Englishintroduction = txtEnglish.Text.Trim();
     if (string.IsNullOrEmpty(policy.htmlUrl))
     {
         policy.htmlUrl = "Preferentialpolicies.htm";
     }
     if (bll.Update(policy))
     {
         PolicyStatic sta = new PolicyStatic();
         if (sta.StaticHtml(int.Parse(policyId.Value.ToString()), loginName) <= 0)
         {
             Response.Write("<script>alert('修改失败!');</script>");
             //Response.Write("<script>alert('修改失败!');document.location='Addpolicy.aspx'</script>");
         }
         else
         {
             //AreaIndexBLL areaBll = new AreaIndexBLL();
             //areaBll.AreaHtml(loginName, 8);
             sta.StaticHtml(loginName);
             Response.Write("<script>alert('修改成功!');location.href='PolicyManage.aspx';</script>");
         }
     }
     else
     {
         Response.Write("<script>alert('修改失败!');</script>");
     }
 }
Esempio n. 15
0
        // POST: api/Policies
        public string Post([FromBody] PolicyModel policy)
        {
            var result = _unitOfWork.Policies.AddPolicy(policy);

            _unitOfWork.Complete();
            return(result);
        }
Esempio n. 16
0
        /// <summary>
        /// 优惠政策
        ///author: desgin by longbin
        ///createdate: 2011-05-09
        ///description: 根据用户名获取优惠政策(index)
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        public string GetPolicyListUIByLoginName(string loginName)
        {
            PolicyDAL     dal   = new PolicyDAL();
            PolicyModel   model = new PolicyModel();
            StringBuilder str   = new StringBuilder();

            model = dal.GetPolicyByName(loginName);
            if (model != null)
            {
                //str.Append("<ul>");
                string str1 = "";
                if (NoHTML(model.Chineseintroduced).Length > 82)
                {
                    str1 = NoHTML(model.Chineseintroduced).Substring(0, 82) + "...";
                }
                else
                {
                    str1 = NoHTML(model.Chineseintroduced);
                }
                str.Append("<p>" + str1);
                str.Append("<a target='_blank' href='http://" + loginName + ".topfo.com/Preferentialpolicies.htm'>[详细]</a></p>");

                //str.Append("</ul>");
            }
            return(str.ToString());
        }
Esempio n. 17
0
        public MessageModel add(object obj)
        {
            PolicyModel s = (PolicyModel)obj;


            string       sql = "insert into policy (role,feature) select '" + s.Role + "','" + s.Feature + "' from DUAL WHERE NOT EXISTS(select id from policy where role = '" + s.Role + "' and feature = '" + s.Feature + "') limit 1 ;";
            MessageModel msg;

            try
            {
                int res = h.ExecuteNonQuery(sql, CommandType.Text);  //ExecuteNonQuery

                if (res > 0)
                {
                    msg = new MessageModel(0, "新建成功", s);
                }
                else
                {
                    msg = new MessageModel(10005, "新建失败或已存在该权限");
                }
            }
            catch (Exception e)
            {
                string err = "服务器错误,请重试!" + e.ToString();
                msg = new MessageModel(10005, err);
            }
            return(msg);
        }
Esempio n. 18
0
        public Task <Unit> Handle(RemovePolicyRequest request, CancellationToken cancellationToken)
        {
            PolicyModel policy = _mapper.Map <PolicyModel>(request);

            _policyService.RemovePolicy(policy);
            throw new NotImplementedException();
        }
        public static PolicyModel PromoteProposalToPolicy(ProposalModel proposal, string policyApprover)
        {
            var proposalToBePromoted = Proposals.FirstOrDefault(p => p.ProposalId == proposal.ProposalId);

            if (proposalToBePromoted != null)
            {
                var newPolicy
                    = new PolicyModel
                    {
                    PolicyId    = (++policyCounter),
                    QuoteId     = proposalToBePromoted.QuoteId,
                    CarPrice    = proposalToBePromoted.CarPrice,
                    VehicleType = proposalToBePromoted.VehicleType,
                    FromDate    = proposalToBePromoted.FromDate,
                    ToDate      = proposalToBePromoted.ToDate,
                    ApproximatePremiumAmount = proposalToBePromoted.ApproximatePremiumAmount,
                    Issuer            = proposalToBePromoted.Issuer,
                    ProposalInitiator = policyApprover,
                    PolicyApprover    = policyApprover
                    };

                Proposals.Remove(proposalToBePromoted);
                Policies.Add(newPolicy);

                return(newPolicy);
            }

            return(null);
        }
Esempio n. 20
0
        public HttpResponseMessage Post(PolicyModel model)
        {
            try
            {
                model.StatusId = GetPolicyStatusId("Active");

                var entity = AutoMapper.Mapper.Map <Policy>(model);
                if (entity.InceptionDate.Year < 1900)
                {
                    entity.InceptionDate = DateTime.Now;
                }

                if (entity.Id == 0)
                {
                    CreateNewPolicy(entity);
                }
                else
                {
                    SaveModifications(entity);
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Esempio n. 21
0
        // PUT: api/Policies/5
        public OkNegotiatedContentResult <string> Put(int id, [FromBody] PolicyModel policy)
        {
            var result = _unitOfWork.Policies.UpdatePolicy(id, policy);

            _unitOfWork.Complete();
            return(Ok(result));
        }
Esempio n. 22
0
        public async Task <IActionResult> CreatePolicy([FromBody] PolicyModel policyModel)
        {
            var accountTransaction = _mapper.Map <Policy>(policyModel);
            var result             = await _policyService.Create(accountTransaction);

            return(Created(string.Empty, _mapper.Map <PolicyModel>(result)));
        }
Esempio n. 23
0
        public async Task <IActionResult> Update(PolicyModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            if (Request.Form.Files != null && Request.Form.Files.Count > 0)
            {
                string savedFileName = string.Empty;
                string path          = Path.Combine(_hostingEnvironment.WebRootPath, FolderName.POLICY_PDF_FOLDER);
                savedFileName = Helper.UploadImage(Request.Form.Files[0], path, model.PolicyId.ToString());
                _logger.LogDebug("Policy file updated successfully.", model.PolicyId);
                model.PolicyFile = savedFileName;
            }

            if ((await _policyBLL.UpdateAsync(model)) > 0)
            {
                _logger.LogDebug("Policy updated successfully.", model.PolicyId);
                ViewData.SetViewData(new StatusModel {
                    TransactionStatus = StatusEnum.Succeed, StatusMessage = string.Format(Message.UPDATE_SUCCESS, "Policy")
                }, HelpingVariable.STATUS);
            }
            else
            {
                _logger.LogDebug("Policy updation failed.", model.PolicyId);
                ViewData.SetViewData(new StatusModel {
                    TransactionStatus = StatusEnum.Failed, StatusMessage = string.Format(Message.UPDATE_FAILURE, "policy")
                }, HelpingVariable.STATUS);
            }

            return(View(model));
        }
Esempio n. 24
0
        /// <summary>
        /// by user name get data
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        public PolicyModel GetPolicyByName(string loginName)
        {
            PolicyModel model = new PolicyModel();
            string      sql   = "select * from dbo.policyTab where loginname='" + loginName + "'";
            DataSet     ds    = DBHelper.Query(sql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["policyId"].ToString() != "")
                {
                    model.policyId = int.Parse(ds.Tables[0].Rows[0]["policyId"].ToString());
                }
                model.Chineseintroduced   = ds.Tables[0].Rows[0]["Chineseintroduced"].ToString();
                model.Englishintroduction = ds.Tables[0].Rows[0]["Englishintroduction"].ToString();
                if (ds.Tables[0].Rows[0]["Clicks"].ToString() != "")
                {
                    model.Clicks = int.Parse(ds.Tables[0].Rows[0]["Clicks"].ToString());
                }
                if (ds.Tables[0].Rows[0]["htmlUrl"].ToString() != "")
                {
                    model.htmlUrl = ds.Tables[0].Rows[0]["htmlUrl"].ToString();
                }
                else
                {
                    model.htmlUrl = "";
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
        public virtual PolicyModel Map(Policy policy)
        {
            var policyModel = new PolicyModel {
                NameOfOwner = policy.OwnerName, PolicyNumber = policy.PolicyNumber
            };

            return(policyModel);
        }
Esempio n. 26
0
        public ActionResult PolicyCreate()
        {
            PolicyModel model = new PolicyModel();

            model.ClientNumber = Convert.ToInt32(Session["ClientId"]);

            return(View(model));
        }
Esempio n. 27
0
 private void bindModel(string loginname)
 {
     policy          = bll.GetPolicyByName(loginname);
     policyId.Value  = policy.policyId.ToString();
     txtClick.Text   = policy.Clicks.ToString();
     txtChina.Text   = policy.Chineseintroduced;
     txtEnglish.Text = policy.Englishintroduction;
 }
Esempio n. 28
0
        public virtual ResponseModel ReceivePolicy(PolicyModel policy)
        {
            var response = new ResponseModel {
                Message = policy.NameOfOwner, Successful = true
            };                                                                                  // Object initializer

            return(response);
        }
Esempio n. 29
0
        public ResponseModel ResponseModelGenerator(PolicyModel policyModel)
        {
            var responseModel = new ResponseModel
            {
                NameOfOwner = policyModel.NameOfOwner, PolicyNumber = policyModel.PolicyNumber
            };

            return(responseModel);
        }
Esempio n. 30
0
        public void Send()
        {
            var policySender = new PolicySender();
            var policyModel  = new PolicyModel();

            var responseModel = policySender.Send(policyModel);

            Assert.IsInstanceOfType(responseModel, typeof(ResponseModel));
        }