Ejemplo n.º 1
0
        public void Insert(ClientPlan clientPlan)
        {
            Error   erro    = new Error();
            Clients clients = (Clients)_pharmaContext.Clients.Select(x => x.idCliente == clientPlan.idCliente);
            Plans   plan    = (Plans)_pharmaContext.Plans.Select(x => x.idPlan == clientPlan.idPlan);

            if (plan.dtFinalVigencia < clients.dtCadastro)
            {
                erro.erro   = "Não é permitido o relacionamento com um plano com vigência final menor que a data de vinculo";
                erro.status = false;
            }
            else if (plan.permitePessoaJuridica == "N" && clients.cpfCnpj.Length <= 14)
            {
                erro.erro   = "Não é permitido pessoa jurídica para o plano escolhido";
                erro.status = false;
            }
            else
            {
                _pharmaContext.ClientPlans.Add(clientPlan);
                _pharmaContext.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 public void Post([FromBody] ClientPlan clientPlan)
 {
     _clientPlan.Insert(clientPlan);
 }
        private void SaveClient()
        {
            //Add Client user
            using (AxaContext ctx = new AxaContext())
            {
                var clientInfo = new Client
                {
                    CLastName        = tb_LastName.Text,
                    CMiddleName      = tb_MiddleName.Text,
                    CFirstName       = tb_FirstName.Text,
                    SpouseLastName   = tb_SLastName.Text,
                    SpouseMiddleName = tb_SMiddleName.Text,
                    SpouseFirstName  = tb_SFirstName.Text,
                    Gender           = cb_Gender.Text,
                    CivilStatus      = cb_CivilStatus.Text,
                    PolicyStatus     = cb_PolicyStatus.Text,
                    CBirthday        = dtp_Dob.Value,
                    Age          = tb_Age.Text,
                    PlaceOfBirth = tb_PlaceOfBirth.Text,
                    Height       = 11,
                    //Height = float.Parse(tb_Height.Text),
                    //Weight = float.Parse(tb_Weight.Text),
                    Weight       = 11,
                    CAddress     = tb_Address.Text,
                    CellphoneNo  = tb_CellphoneNo.Text,
                    TelephoneNo  = tb_TelephoneNo.Text,
                    EmailAddress = tb_EmailAddress.Text,
                    Occupation   = tb_COccupation.Text,
                    //WorkSalary = float.Parse(tb_CWorkSalary.Text),
                    //BusinessIncome = float.Parse(tb_CBusinessIncome.Text),
                    //OtherSource = float.Parse(tb_COtherSource.Text),
                    WorkSalary       = 11,
                    BusinessIncome   = 11,
                    OtherSource      = 11,
                    CompanyName      = tb_CName.Text,
                    CompanyAddress   = tb_CAddress.Text,
                    CompanyContact   = tb_CompanyContactNo.Text,
                    NatureOfBusiness = tb_CNatureOfBusiness.Text,
                    TaxIdNumber      = tb_TaxIdentication.Text,
                    Sss_gsisNumber   = tb_SSSorGSIS_Number.Text,
                    ValidId1         = idPic1.Text,
                    ValidId2         = idPic2.Text,
                    //   EmployeeId = tempEmployeeId
                    EmployeeId = 1
                };
                ctx.Clients.Add(clientInfo);
                ctx.SaveChanges();


                // save client plan
                var clientPlan = new ClientPlan();
                for (int row = 0; row < dataGridView_LoadPlans.Rows.Count; row++)
                {
                    clientPlan.PolicyNo      = dataGridView_LoadPlans.Rows[row].Cells["col_PolicyNo"].Value.ToString();
                    clientPlan.SumInsured    = dataGridView_LoadPlans.Rows[row].Cells["col_SumInsured"].Value.ToString();
                    clientPlan.ModeOfPayment = dataGridView_LoadPlans.Rows[row].Cells["col_ModeOfPayment"].Value.ToString();
                    clientPlan.DueOfPayment  = Int32.Parse(dataGridView_LoadPlans.Rows[row].Cells["col_DueOfPayment"].Value.ToString());


                    string tempPlanCategory = dataGridView_LoadPlans.Rows[row].Cells["col_PlanCategory"].Value.ToString();
                    string tempPlanAvail    = dataGridView_LoadPlans.Rows[row].Cells["col_PlanAvail"].Value.ToString();
                    var    tempPlanId       = ctx.Plans.Where(x => x.Category == tempPlanCategory && x.Description == tempPlanAvail).Select(p => p.PlanId).FirstOrDefault().ToString();



                    clientPlan.PlanId   = Convert.ToInt32(tempPlanId);
                    clientPlan.ClientId = clientInfo.ClientId;
                    ctx.ClientPlans.Add(clientPlan);
                    ctx.SaveChanges();
                }
            }
        }