Example #1
0
        public List <ItemInfo> GetItems()
        {
            IDataReader dataReader = null;

            try
            {
                List <ItemInfo> itemList = new List <ItemInfo>();
                ItemInfo        itemInfo = null;

                Database db = DatabaseFactory.CreateDatabase("DbConnection");
                dataReader = BillingDAL.GetItems(db);
                while (dataReader.Read())
                {
                    itemInfo                 = new ItemInfo();
                    itemInfo.ItemID          = Common.GetInt32(dataReader, "FITEMID");
                    itemInfo.ItemName        = Common.GetString(dataReader, "FITEMNAME");
                    itemInfo.ItemDescription = Common.GetString(dataReader, "FITEMDESC");
                    itemInfo.Price           = Common.GetDecimal(dataReader, "FPRICE");
                    itemList.Add(itemInfo);
                }
                dataReader.Close();

                return(itemList);
            }
            catch (Exception ex)
            {
                Common.LogException(ex);
                throw new WebFaultException <string>(ex.Message, HttpStatusCode.InternalServerError);
            }
            finally
            {
                if (dataReader != null && !dataReader.IsClosed)
                {
                    dataReader.Close();
                }
            }
        }