예제 #1
0
        public async Task <IActionResult> Details(Guid id, CancellationToken cancellationToken)
        {
            Flight flight = await flightManager.GetUserFlightAsync(id, cancellationToken);

            UserFlightViewModel userFlightViewModel = new UserFlightViewModel()
            {
                FlightId      = flight.FlightId,
                Date          = flight.Date.ToString("yyyy-MM-dd"),
                Duration      = String.Format("{0} óra, {1} perc, {2} másodperc", flight.DurationHours, flight.DurationMins, flight.DurationSeconds),
                DepartureName = flight.DepartureLocation.Name,
                ArrivalName   = flight.ArrivalLocation?.Name,
                Status        = flight.FlightStatus.GetDescription(),
                OptGPSRecords = JsonConvert.SerializeObject(flight.GPSRecords.Where(ent => ent.IsOptimized).Select(x => new
                {
                    Latitude  = x.Latitude,
                    Longitude = x.Longitude,
                    ColorA    = x.ColorA,
                    ColorR    = x.ColorR,
                    ColorG    = x.ColorG,
                    ColorB    = x.ColorB
                })),
                GPSRecords = JsonConvert.SerializeObject(flight.GPSRecords.Select(x => new
                {
                    Latitude  = x.Latitude,
                    Longitude = x.Longitude,
                    ColorA    = x.ColorA,
                    ColorR    = x.ColorR,
                    ColorG    = x.ColorG,
                    ColorB    = x.ColorB
                }))
            };

            if (userFlightViewModel.ArrivalName == null)
            {
                userFlightViewModel.ArrivalName = "Terep";
            }
            return(View(userFlightViewModel));
        }
예제 #2
0
        public async Task <IActionResult> Index(CancellationToken cancellationToken)
        {
            List <Flight> flights = await flightManager.GetUserFlightsAsync(cancellationToken);

            List <UserFlightViewModel> userFlightViewModels = new List <UserFlightViewModel>();

            foreach (var f in flights)
            {
                UserFlightViewModel userFlightViewModel = new UserFlightViewModel();
                userFlightViewModel.FlightId      = f.FlightId;
                userFlightViewModel.Date          = f.Date.ToString("yyyy-MM-dd");
                userFlightViewModel.Duration      = String.Format("{0} óra, {1} perc, {2} másodperc", f.DurationHours, f.DurationMins, f.DurationSeconds);
                userFlightViewModel.DepartureName = f.DepartureLocation.Name;
                userFlightViewModel.ArrivalName   = f.ArrivalLocation?.Name;
                if (userFlightViewModel.ArrivalName == null)
                {
                    userFlightViewModel.ArrivalName = "Terep";
                }
                userFlightViewModel.Status = f.FlightStatus.GetDescription();
                userFlightViewModels.Add(userFlightViewModel);
            }
            return(View(userFlightViewModels));
        }