コード例 #1
0
ファイル: RouteManager.cs プロジェクト: nattfari/oceanic
        private long SaveRoute(CalculationManager.Node destination, forsendelse rute, pakke pakke)
        {
            if (destination.Previous == null)
            {
                rute.pakke = pakke;
                rute.StartBy = destination.By.CityId;
                return DataManager.OpretRute(rute);
            }

            if (rute.SlutBy == null)
                rute.SlutBy = destination.By.CityId;

            var sd = destination.Previous.Ruter.FirstOrDefault(p => p.From == destination.Previous && p.To == destination);

            var forsendelse = new forsendelsesRute();
            forsendelse.StartBy = destination.Previous.By.CityId;
            forsendelse.SlutBy = destination.By.CityId;
            forsendelse.Price = Convert.ToUInt32(sd.Route.Pris);
            forsendelse.TransportTime = sd.Route.Rute.Time;
            forsendelse.TransportType = (Int64)sd.Route.TransportType;

            rute.forsendelsesRute.Add(forsendelse);

            return SaveRoute(destination.Previous, rute, pakke);
        }
コード例 #2
0
ファイル: DataManager.cs プロジェクト: nattfari/oceanic
 public static long OpretRute(forsendelse rute)
 {
     using (var context = new OADbContext())
     {
         var id = context.forsendelse.Add(rute);
         context.SaveChanges();
         return id.Id;
     }
 }