public void TestGoodsService_AddGoods()
        {

            Goods goods = new Goods();
            goods.id = "A001";
            goods.name = "舒跑";
            goods.price = 25;
            goods.count = 40;
            goods.describe = "發燒喝舒跑";
            goods.time = new DateTime(2015, 06, 26);
            goods.type = "飲料";
            GoodsService.AddGoods(goods);

            Goods dbGoods = GoodsService.GetGoodsByName(goods.name);
            Assert.IsNotNull(dbGoods);
            Assert.AreEqual(goods.name, dbGoods.name);

            Console.WriteLine("編號為 = " + dbGoods.id);
            Console.WriteLine("名稱為 = " + dbGoods.name);
            Console.WriteLine("價格為 = " + dbGoods.price);
            Console.WriteLine("數量為 = " + dbGoods.count);
            Console.WriteLine("描述為 = " + dbGoods.describe);
            Console.WriteLine("時間為 = " + dbGoods.time);
            Console.WriteLine("種類為 = " + dbGoods.type);

            GoodsService.DeleteGoods(dbGoods);
            dbGoods = GoodsService.GetGoodsByName(goods.name);
            Assert.IsNull(dbGoods);
        }
        public void DeleteGoods(Goods goods)
        {
            goods = GoodsDao.GetGoodsByName(goods.name);

            if (goods != null)
            {
                GoodsDao.DeleteGoods(goods);
            }
        }
 public void DeleteGoods(Goods goods)
 {
     try
     {
         GoodsService.DeleteGoods(goods);
     }
     catch (Exception)
     {
         throw new HttpResponseException(HttpStatusCode.InternalServerError);
     }
 }
        public Goods AddGoods(Goods goods)
        {
            CheckGoodsIsNotNullThrowException(goods);

            try
            {
                return GoodsService.AddGoods(goods);
            }
            catch (Exception)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
        public Goods UpdateGoods(Goods goods)
        {
            CheckGoodsIsNullThrowException(goods);

            try
            {
                GoodsService.UpdateGoods(goods);
                return GoodsService.GetGoodsByName(goods.name);
            }
            catch (Exception)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
        /// <summary>
        ///     檢查課程資料是否存在,如果存在則拋出錯誤.
        /// </summary>
        /// <param name="course">
        ///     課程資料.
        /// </param>
        private void CheckGoodsIsNotNullThrowException(Goods goods)
        {
            Goods dbGoods = GoodsService.GetGoodsById(goods.id);

            if (dbGoods != null)
            {
                throw new HttpResponseException(HttpStatusCode.Conflict);
            }
        }
        /// <summary>
        ///     檢查課程資料是否存在,如果不存在則拋出錯誤.
        /// </summary>
        /// <param name="course">
        ///     課程資料.
        /// </param>
        
        private void CheckGoodsIsNullThrowException(Goods goods)
        {
            Goods dbGoods = GoodsService.GetGoodsById(goods.id);

            if (dbGoods != null)
            {
                
            }
        }
 public void UpdateGoods(Goods goods)
 {
     GoodsDao.UpdateGoods(goods);
 }
 public Goods AddGoods(Goods goods)
 {
     GoodsDao.AddGoods(goods);
     return GetGoodsByName(goods.name);
 }