Exemplo n.º 1
0
        public void InsertArrivalTimes(IEnumerable<ArrivalTimeData> arrivalTimes)
        {
            using (var database = new DataClassesDataContext())
            {
                foreach (var arrivalTime in arrivalTimes)
                {
                    var result = new ArrivalTime();
                    database.ArrivalTimes.InsertOnSubmit(result);

                    var restaurant = database.Restaurants.FirstOrDefault(r => r.Name == arrivalTime.Restaurant.Name);

                    if (restaurant == default(Restaurant))
                    {
                        restaurant = new Restaurant();
                        restaurant.Name = arrivalTime.Restaurant.Name;
                        database.Restaurants.InsertOnSubmit(restaurant);
                    }

                    result.Restaurant = restaurant;
                    result.TimeArrived = arrivalTime.TimeArrived;
                    database.ArrivalTimes.InsertOnSubmit(result);
                }

                database.SubmitChanges();
            }
        }
Exemplo n.º 2
0
 partial void UpdateRestaurant(Restaurant instance);
Exemplo n.º 3
0
 partial void DeleteRestaurant(Restaurant instance);
Exemplo n.º 4
0
 partial void InsertRestaurant(Restaurant instance);