예제 #1
0
 private void SavePolicy(string paymentId)
 {
     using (InsuranceConnection context = new InsuranceConnection())
     {
         Policy policy = new Policy();
         policy.CarID    = Convert.ToInt16(Session["CarID"]);
         policy.DriverID = Convert.ToInt16(Session["DriverID"]);
         if (!(Convert.ToString(Session["AddDriverID"]).Equals("false")))
         {
             policy.AdditionalDriverID = Convert.ToInt16(Session["AddDriverID"]);
         }
         policy.PaymentID = paymentId;
         policy.Quote     = Convert.ToDecimal(Session["quote"]);
         DateTime endDate = Convert.ToDateTime(Session["startDate"]).AddYears(1);
         policy.StartDate = Convert.ToDateTime(Session["startDate"]);
         policy.EndDate   = endDate;
         context.Policies.Add(policy);
         int driverID = int.Parse(Session["DriverID"].ToString());
         int policyID = policy.Id;
         var query    = from p in context.Drivers
                        where p.Id == driverID
                        select p;
         Driver i = query.FirstOrDefault();
         i.PolicyId = policyID;
         context.SaveChanges();
     }
 }
예제 #2
0
 private void FillDetails()
 {
     using (InsuranceConnection context = new InsuranceConnection())
     {
         var queryOne = from p in context.Drivers
                        where p.SiteUserId == userId
                        select p;
         Driver driver   = queryOne.FirstOrDefault();
         var    queryTwo = from p in context.ContactDetails
                           where p.AppUserID == userId
                           select p;
         ContactDetail contact = queryTwo.FirstOrDefault();
         if (driver != null)
         {
             FirstName.Text = driver.FirstName;
             LastName.Text  = driver.SecondName;
         }
         if (contact != null)
         {
             Phone.Text  = contact.Phone.ToString();
             County.Text = contact.County;
             Email.Text  = contact.Email;
         }
     }
 }
예제 #3
0
        private void saveAdditionalDriver()
        {
            if (AdditionalDriverFlag.Equals("true"))
            {
                using (InsuranceConnection context = new InsuranceConnection())
                {
                    AdditionalDriver add = new AdditionalDriver();
                    add.AppUserId  = AppUserId;
                    add.Title      = AdditionalDriverTitle;
                    add.FirstName  = AdditionalDriverFirstName;
                    add.SecondName = AdditionalDriverSecondName;
                    context.AdditionalDrivers.Add(add);

                    ContactDetail con = new ContactDetail();
                    con.AppUserID = AppUserId;
                    con.Phone     = AdditionalDriverPhone;
                    con.DOB       = AdditionalDriverDOB;
                    con.Email     = AdditionalDriverEmail;
                    con.County    = AdditionalDriverCounty;
                    con.AddDriver = true;
                    context.ContactDetails.Add(con);
                    context.SaveChanges();
                    Session["AddDriverID"] = add.Id;
                }
            }
            else
            {
                Session["AddDriverID"] = false;
            }
        }
예제 #4
0
 private void SaveQuote()
 {
     using (InsuranceConnection context = new InsuranceConnection())
     {
         Quote price = new Quote();
         price.AppUserId      = user;
         price.Price          = quote;
         price.RejectDecision = false;
         price.DOC            = DateTime.Today;
         context.Quotes.Add(price);
         context.SaveChanges();
         Session["QuoteID"] = price.Id;
     }
 }
예제 #5
0
 protected void UpdateDetails_Click(object sender, EventArgs e)
 {
     using (InsuranceConnection context = new InsuranceConnection())
     {
         var query = from p in context.ContactDetails
                     where p.AppUserID == userId
                     select p;
         ContactDetail contact = query.FirstOrDefault();
         contact.Email = UpdateEmail.Text;
         contact.Phone = UpdatePhone.Text;
         context.SaveChanges();
     }
     FillDetails();
 }
예제 #6
0
 protected void ModalUpdateButton_Click(object sender, EventArgs e)
 {
     using (InsuranceConnection context = new InsuranceConnection())
     {
         var id    = int.Parse(Label1.Text);
         var query = from p in context.Policies
                     where p.Id == id
                     select p;
         Policy pol = query.FirstOrDefault();
         pol.Checked  = CheckBoxChecked.Checked;
         pol.Rejected = CheckBoxRejected.Checked;
         context.SaveChanges();
         FetchData(ConnectionStr, GD1);
     }
 }
예제 #7
0
 private void saveCar()
 {
     using (InsuranceConnection context = new InsuranceConnection())
     {
         Car car = new Car();
         car.AppUserID = AppUserId;
         car.RegNumber = Reg;
         car.DOM       = DOM;
         car.Make      = Make;
         car.Model     = Model;
         car.Engine    = Engine;
         context.Cars.Add(car);
         context.SaveChanges();
         Session["CarID"] = car.Id;
     }
 }
예제 #8
0
 private void saveDrivingHistory()
 {
     using (InsuranceConnection context = new InsuranceConnection())
     {
         DrivingHistory dh = new DrivingHistory();
         dh.AppUserId      = AppUserId;
         dh.LicenceNo      = LicenceNo;
         dh.ClaimsDiscount = Bonus;
         if (ConvictionsFlag)
         {
             dh.ConvictionType = ConvictionType;
             dh.ConvictionDate = ConvictionDate;
         }
         if (ClaimsFlag)
         {
             dh.AccidentType = ClaimType;
             dh.AccidentDate = ClaimDate;
         }
         context.DrivingHistories.Add(dh);
         context.SaveChanges();
     }
 }
예제 #9
0
        private void saveDriver()
        {
            using (InsuranceConnection context = new InsuranceConnection())
            {
                Driver driver = new Driver();
                driver.Title      = DriverTitle;
                driver.FirstName  = FirstName;
                driver.SecondName = SecondName;
                driver.SiteUserId = AppUserId;
                context.Drivers.Add(driver);

                ContactDetail contact = new ContactDetail();
                contact.AppUserID = AppUserId;
                contact.Phone     = Phone;
                contact.DOB       = DOB;
                contact.Email     = Email;
                contact.County    = County;
                contact.AddDriver = false;
                context.ContactDetails.Add(contact);
                context.SaveChanges();
                Session["DriverID"] = driver.Id;
            }
        }