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); }
public static long OpretRute(forsendelse rute) { using (var context = new OADbContext()) { var id = context.forsendelse.Add(rute); context.SaveChanges(); return id.Id; } }