Example #1
0
        public int AddTruck(DataService dataService, User user)
        {
            // Create the truck, driver, and route
            //
            Truck truck = new Truck
            {
                Name = TruckName,
                PlateNumber = TruckPlate,
                Type = TruckType,
                IsPrivate = IsPrivate,
                User = user
            };
            IEnumerable<string> brokenRules;
            dataService.Trucks.Add(truck, out brokenRules);

            // Add the intial position of the truck
            //
            Location startLocation = new Location
                                         {
                                             Latitude = LatValue,
                                             Longitude = LngValue,
                                             Timestamp = DateTime.Now,
                                             Truck = truck
                                         };
            dataService.Locations.Add(startLocation, out brokenRules);

            dataService.Commit();

            return truck.Id;
        }