public int AddOrder(Order order) { try { _db.BeginTransaction(); // Do transacted updates here var poco = _orderMapper.MapToPoco(order); var insertResult = _db.Insert("Orders", "Id", poco); var id = Convert.ToInt32(insertResult); foreach (var orderedMeal in poco.OrderedMeals) { orderedMeal.OrderId = id; _db.Insert("OrderedMeals", "Id", orderedMeal); } // Commit _db.CompleteTransaction(); return(id); } catch (Exception) { _db.AbortTransaction(); throw; } }
public int AddRestaurant(Restaurant restaurant) { var poco = _mapper.MapToPoco(restaurant); var id = _db.Insert("Restaurants", "Id", poco); return(decimal.ToInt32((decimal)id)); }
public void AddOrderedMeal(OrderedMeal orderedMeal) { var orderedMealPoco = _mealMapper.MapToPoco(orderedMeal); _db.Insert("OrderedMeals", "Id", orderedMealPoco); }