Пример #1
0
        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;
            }
        }
Пример #2
0
        public int AddRestaurant(Restaurant restaurant)
        {
            var poco = _mapper.MapToPoco(restaurant);

            var id = _db.Insert("Restaurants", "Id", poco);

            return(decimal.ToInt32((decimal)id));
        }
Пример #3
0
        public void AddOrderedMeal(OrderedMeal orderedMeal)
        {
            var orderedMealPoco = _mealMapper.MapToPoco(orderedMeal);

            _db.Insert("OrderedMeals", "Id", orderedMealPoco);
        }