Esempio n. 1
0
        public IEnumerable <TruckLocationViewModel> MockTruckLocationList()
        {
            var truckLocationlist = new TruckLocationViewModel[]
            {
                new TruckLocationViewModel
                {
                    TruckId             = "CR-12345",
                    TruckDriverFullname = "DriverA",
                    Latitude            = Convert.ToSingle(12.02151),
                    Longitude           = Convert.ToSingle(121.02151),
                    TruckCurrentAddress = "Chiang Mai",
                    TruckCurrentTime    = new DateTime(2017, 12, 3, 8, 40, 00)
                },
                new TruckLocationViewModel
                {
                    TruckId             = "CM-1457",
                    TruckDriverFullname = "DriverB",
                    Latitude            = Convert.ToSingle(13.02151),
                    Longitude           = Convert.ToSingle(98.02151),
                    TruckCurrentAddress = "Bangkok",
                    TruckCurrentTime    = new DateTime(2017, 8, 12, 5, 50, 30)
                }
            };

            return(truckLocationlist);
        }
        public IEnumerable <TruckLocationViewModel> GetAllTruckLocations()
        {
            List <TruckLocationViewModel> truckLocationVMlist = new List <TruckLocationViewModel>(); // to hold list of Customer and order details
            var truckLocationlist = (
                from truckLocation in _context.TruckLocations
                join truckDriver in _context.TruckDrivers on
                truckLocation.TruckDriverId equals truckDriver.TruckDriverId
                select new
            {
                truckDriver.TruckId,
                truckDriver.TruckDriverFullname,
                truckLocation.Latitude,
                truckLocation.Longitude,
                truckLocation.TruckCurrentTime,
                truckLocation.TruckCurrentAddress
            }).ToList();

            //query getting data from database from joining two tables and storing data in customerlist
            foreach (var item in truckLocationlist)
            {
                var truckLocationViewModel = new TruckLocationViewModel(); // ViewModel
                truckLocationViewModel.TruckId             = item.TruckId;
                truckLocationViewModel.TruckDriverFullname = item.TruckDriverFullname;
                truckLocationViewModel.Latitude            = item.Latitude;
                truckLocationViewModel.Longitude           = item.Longitude;
                truckLocationViewModel.TruckCurrentTime    = item.TruckCurrentTime;
                truckLocationViewModel.TruckCurrentAddress = item.TruckCurrentAddress;

                truckLocationVMlist.Add(truckLocationViewModel);
            }

            return(truckLocationVMlist.ToList());
        }
Esempio n. 3
0
        public TruckLocationViewModel MockTruckLocationViewModel()
        {
            var truckLocation = new TruckLocationViewModel
            {
                TruckId             = "CR-12345",
                TruckDriverFullname = "DriverA",
                Latitude            = Convert.ToSingle(12.02151),
                Longitude           = Convert.ToSingle(121.02151),
                TruckCurrentAddress = "Chiang Mai",
                TruckCurrentTime    = new DateTime(2017, 12, 3, 8, 40, 00)
            };

            return(truckLocation);
        }