Exemple #1
0
        public static Quote convertViewModelToQuote(ActiveQuoteViewModel quoteVM)
        {
            Quote quote = new Quote();

            quote.ClaimInLastFive    = quoteVM.ClaimInLastFive;
            quote.CustomerAddress    = quoteVM.CustomerAddress;
            quote.CustomerDob        = quoteVM.CustomerDob;
            quote.CustomerFirstName  = quoteVM.CustomerName.Split(' ')[0];
            quote.CustomerLastName   = quoteVM.CustomerName.Split(' ')[1];
            quote.CustomerPhone      = quoteVM.CustomerPhone;
            quote.CustomerSsn        = quoteVM.CustomerSsn;
            quote.ForceMultiDiscount = quoteVM.ForceMultiDiscount;
            quote.Id = quoteVM.Id;
            quote.MovingViolation = quoteVM.MovingViolation;
            quote.PreviousCarrier = quoteVM.PreviousCarrier;
            quote.Price           = (decimal)quoteVM.Price;
            quote.State           = quoteVM.State;
            quote.Submitted       = quoteVM.Submitted;
            var times = quoteVM.SubmissionTime.Split('/');

            quote.SubmissionTime = new DateTime(Convert.ToInt32(times[1]), Convert.ToInt32(times[0]), Convert.ToInt32(times[2]));
            quote.User           = quoteVM.User;
            quote.AIAUserId      = quoteVM.AIAUserId;
            ObservableCollection <Driver> drivers = new ObservableCollection <Driver>();

            foreach (var driver in quoteVM.Drivers)
            {
                drivers.Add(Converter.convertDriverViewModelToDriver(driver));
            }
            quote.Drivers = drivers;
            ObservableCollection <Vehicle> vehicles = new ObservableCollection <Vehicle>();

            foreach (var vehicle in quoteVM.Vehicles)
            {
                vehicles.Add(Converter.convertVehicleViewModelToVehicle(vehicle));
            }
            quote.Drivers  = drivers;
            quote.Vehicles = vehicles;

            return(quote);
        }
Exemple #2
0
        public static ActiveQuoteViewModel convertQuoteToViewModel(Quote quote)
        {
            ActiveQuoteViewModel quoteVM = new ActiveQuoteViewModel();

            quoteVM.ClaimInLastFive    = quote.ClaimInLastFive;
            quoteVM.CustomerAddress    = quote.CustomerAddress;
            quoteVM.CustomerDob        = quote.CustomerDob;
            quoteVM.CustomerName       = quote.CustomerFirstName + " " + quote.CustomerLastName;
            quoteVM.CustomerPhone      = quote.CustomerPhone;
            quoteVM.CustomerSsn        = quote.CustomerSsn;
            quoteVM.ForceMultiDiscount = quote.ForceMultiDiscount;
            quoteVM.Id = quote.Id;
            quoteVM.MovingViolation = quote.MovingViolation;
            quoteVM.PreviousCarrier = quote.PreviousCarrier;
            quoteVM.Price           = (double)quote.Price;
            quoteVM.State           = quote.State;
            quoteVM.Submitted       = quote.Submitted;
            quoteVM.SubmissionTime  = quote.SubmissionTime.ToString().Split(' ')[0];
            quoteVM.User            = quote.User;
            quoteVM.AIAUserId       = quote.AIAUserId;
            ObservableCollection <DriverViewModel> dvmcollection = new ObservableCollection <DriverViewModel>();

            foreach (var driver in quote.Drivers)
            {
                dvmcollection.Add(Converter.convertDriverToDriverViewModel(driver));
            }
            quoteVM.Drivers = dvmcollection;
            ObservableCollection <VehicleViewModel> vvmcollection = new ObservableCollection <VehicleViewModel>();

            foreach (var vehicle in quote.Vehicles)
            {
                vvmcollection.Add(Converter.convertVehicletoVehicleViewModel(vehicle));
            }
            quoteVM.Vehicles = vvmcollection;
            return(quoteVM);
        }