Exemple #1
0
        public Shop GetShopByID(int shopid)
        {
            DbParameter shopIdParameter = _db.CreateParameter(DbNames.GETSHOPBYSHOPID_SHOPID_PARAMETER, shopid);

            _db.Open();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETSHOPBYSHOPID_STOREDPROC, CommandType.StoredProcedure, shopIdParameter);

            int ordinalShop_shopid      = reader.GetOrdinal(DbNames.SHOP_SHOPID);
            int ordinalShop_ownerid     = reader.GetOrdinal(DbNames.SHOP_OWNERID);
            int ordinalShop_name        = reader.GetOrdinal(DbNames.SHOP_NAME);
            int ordinalShop_description = reader.GetOrdinal(DbNames.SHOP_DESCRIPTION);
            int ordinalShop_money       = reader.GetOrdinal(DbNames.SHOP_MONEY);

            Shop   newShop    = null;
            int    shopId     = -1;
            int    ownerId    = -1;
            int    totalMoney = -1;
            string name       = null;
            string desc       = null;

            while (reader.Read())
            {
                shopId     = reader.GetInt32(ordinalShop_shopid);
                ownerId    = reader.GetInt32(ordinalShop_ownerid);
                totalMoney = reader.GetInt32(ordinalShop_money);
                name       = reader.GetString(ordinalShop_name);
                desc       = reader.GetString(ordinalShop_description);
            }

            reader.Close();
            _db.Close();

            // add new list creating thing to load shop items ^_ ^
            List <BaseItem> items = itemDataManager.GetShopItemsByOwnerID(ownerId);

            newShop = new Shop(name, desc, shopid, totalMoney, ownerId, items);

            return(newShop);
        }