示例#1
0
 public static void Admin()
 {
     using (var ctx = new InsuranceContext())
     {
         foreach (Quote quote in ctx.Quotes)
         {
             var customer = ctx.Customers.Where(x => x.ID == quote.CustomerID).First();
             quote.ViewQuote(customer);
             Console.ReadLine();
         }
     }
 }
示例#2
0
        static void Main(string[] args)
        {
            Customer customer = new Customer();

            if (customer.BuildCustomer())
            {
                Admin();
                return;
            }
            // Check if customer exists
            // if query returns null, Add() new customer
            // else customer object is reassigned from DB
            using (var ctx = new InsuranceContext())
            {
                var customerQuery = ctx.Customers.FirstOrDefault(s => s.Email == customer.Email);
                if (customerQuery == null)
                {
                    ctx.Customers.Add(customer);
                    ctx.SaveChanges();
                }
                else
                {
                    customer = customerQuery;
                }
            }

            Console.WriteLine("Your Customer ID is {0}", customer.ID);

            Quote quote = new Quote();

            quote.NewQuote(customer);


            // Add quote to Database
            using (var ctx = new InsuranceContext())
            {
                ctx.Quotes.Add(quote);
                ctx.SaveChanges();
            }

            quote.ViewQuote(customer);
            Console.ReadLine();
        }
示例#3
0
 public void ViewQuote(Customer Customer)
 {
     using (var ctx = new InsuranceContext())
     {
     }
     Console.WriteLine("Quote # {0} issued on {1} at {2}", QuoteID, QuoteDateTime.Date.ToShortDateString(), QuoteDateTime.ToShortTimeString());
     Console.WriteLine("{0} {1} {2}", CarYear, CarMake, CarModel);
     Console.WriteLine("Cust ID: {0} {1} {2}\n\t{3} {4}", Customer.ID, Customer.FirstName, Customer.LastName,
                       Customer.Email, Customer.DOB.ToShortDateString());
     if (DUI)
     {
         Console.WriteLine("Has DUI!");
     }
     if (Tickets > 0)
     {
         Console.WriteLine("Speeding Tickets: {0}", Tickets);
     }
     Console.WriteLine(Factors);
     Console.WriteLine("Monthy Premium: ${0}", QuotePrice);
 }