Exemple #1
0
        public async Task Add([FromServices] ICommonActions <Dealer> dealerSource, [FromBody] CarInfoViewModel model)
        {
            if (model == null)
            {
                return;
            }

            var dealerList = await dealerSource.GetAllAsync();

            var dealer = dealerList
                         .Where(x => x.Id == model.DealerId)
                         .FirstOrDefault();

            if (dealer == null)
            {
                return;
            }

            Car car = new Car()
            {
                Id            = model.Id,
                CarState      = model.CarState.Equals("new", StringComparison.InvariantCultureIgnoreCase) ? CarState.New : CarState.IsStock,
                ColorExterior = model.ColorExterior,
                ColorInterior = model.ColorInterior,
                Dealer        = dealer,
                Name          = model.Name,
                Price         = model.Price,
                VinCode       = model.VinCode,
                CarStatus     = CarStatus.Active,
                NativeId      = "None"
            };
            await _carinfo.AddAsync(car);
        }
        public ActionResult ChooseSeats(int [] selectedSeats, CarInfoViewModel model)
        {
            if (selectedSeats == null)
            {
                selectedSeats = new int[0];
            }

            RouteInfo = Session["RouteInfo"] as RouteInfoViewModel;
            RouteInfo.SelectedCarriage = model;

            var    routeModel = mapperControl.GetRouteInfoByRouteInfoViewModel(RouteInfo);
            double price      = priceCalculateService.GetPrice(routeModel);

            RouteInfo.SelectedCarriage.ChosenSeats = new List <SelectedSeat>();

            for (int i = 0; i < selectedSeats.Length; i++)
            {
                RouteInfo.SelectedCarriage.ChosenSeats.Add(new SelectedSeat {
                    Number = selectedSeats[i], Price = price
                });
            }

            Session["RouteInfo"] = RouteInfo;

            return(PartialView(model));
        }
Exemple #3
0
        public CarInfoPage(CarInfoViewModel viewModel)
        {
            NavigationPage.SetBackButtonTitle(this, string.Empty);

            InitializeComponent();
            viewModel.Navigation = Navigation;

            BindingContext = viewModel;
        }
Exemple #4
0
        public MainViewModel()
        {
            var configHelper = new ConfigurationHelper();

            var configuration = configHelper.LoadConfiguration();

            Status     = new StatusBarViewModel();
            Weather    = new WeatherViewModel(configuration.GetFeature("weather"));
            Departures = new DeparturesViewModel(configuration.GetFeature("departures"));
            Agenda     = new AgendaWorker(configuration.GetFeature("agenda"));
            CarInfo    = new CarInfoViewModel(configuration.GetFeature("carInfo"));
        }
        public ActionResult CarInfo(int carId)
        {
            CarInfoViewModels = Session["TrainInfo"] as List <CarInfoViewModel>;
            CarInfoViewModel model    = new CarInfoViewModel();
            string           viewName = String.Empty;

            foreach (var car in CarInfoViewModels)
            {
                if (car.CarriageId == carId)
                {
                    model = car;
                    CheckCarType(model.Name, ref viewName);
                    break;
                }
            }
            return(PartialView(viewName, model));
        }
        private void ReloadEntryList()
        {
            // We'll expect a entry_list.ini where the car definitions are stored (you can use a real one)
            Cars.Clear();

            if (!File.Exists(@"cfg\entry_list.ini") && !System.ComponentModel.DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject()))
                throw new Exception("We'd expect a cfg/entry_list.ini next to the acServerFake.exe. You can use a real one.");

            // Now some ugly ini-parsing, but I didn't want to add a whole lib as dependancy
            CarInfoViewModel currentCarInfo = null;
            foreach (var line in File.ReadAllLines(@"cfg\entry_list.ini"))
            {
                if (line.StartsWith("[CAR_"))
                {
                    currentCarInfo = new CarInfoViewModel();
                    currentCarInfo.Message.CarId = Convert.ToByte(line.Replace("[CAR_", "").Replace("]", ""));
                    Cars.Add(currentCarInfo);
                }
                else if (line.StartsWith("MODEL="))
                    currentCarInfo.Message.CarModel = line.Replace(("MODEL="), "");
                else if (line.StartsWith("SKIN="))
                    currentCarInfo.Message.CarSkin = line.Replace(("SKIN="), "");
                else if (line.StartsWith("DRIVERNAME="))
                {
                    currentCarInfo.Message.DriverName = line.Replace(("DRIVERNAME="), "");
                    if (!string.IsNullOrEmpty(currentCarInfo.Message.DriverName))
                        currentCarInfo.Message.IsConnected = true;
                }
                else if (line.StartsWith("TEAM="))
                    currentCarInfo.Message.DriverTeam = line.Replace(("TEAM="), "");
                else if (line.StartsWith("GUID="))
                {
                    currentCarInfo.Message.DriverGuid = line.Replace(("GUID="), "");
                    if (!string.IsNullOrEmpty(currentCarInfo.Message.DriverName))
                        currentCarInfo.Message.IsConnected = true;
                }
            }
        }
Exemple #7
0
        public CarInfoViewModel CarInfoViewModelFactory(int id, DateTime?dateFrom, DateTime?dateTo)
        {
            Car car = carService.GetById(id);

            IQueryable <Location> locations = (dateFrom.HasValue && dateTo.HasValue) ? locationService.GetMany(s => s.CarId == id && s.Time >= dateFrom && s.Time <= dateTo)
                : locationService.GetMany(s => s.CarId == car.Id);

            IQueryable <Location> AllLocations = locationService.GetMany(s => s.CarId == car.Id);

            CarInfoViewModel model = new CarInfoViewModel();

            model.UserCar                                 = car;
            model.SpeedChart                              = ChartHelper.SpeedChart(car, locations);
            model.AverageSpeedPerPeriod                   = ChartHelper.AverageSpeedPerSelectedPeriod(car, locations, "chart2");
            model.AverageSpeedPerAllTime                  = ChartHelper.AverageSpeedPerSelectedPeriod(car, AllLocations, "chart3");
            model.AverageFuelCompsuntionPerAllTime        = ChartHelper.AverageFuelConsumption(car, AllLocations, "chart4");
            model.AverageFuelCompsuntionPerSelectedPeriod = ChartHelper.AverageFuelConsumption(car, locations, "chart5");
            model.ThrotleChart                            = ChartHelper.ThrotleChart(car, locations);
            model.MillageChart                            = ChartHelper.MillageChart(car, locations);
            model.FuelChart                               = ChartHelper.FuelChart(car, locations);

            return(model);
        }