using System;
using System.Collections.Generic;
using System.Text;
using Model;
using ImpDDal;
using IDDal;
/*******菜肴种类的业务逻辑层**********
 * 提供菜肴种类的增加,删除,修改,查询
 * 设计者:魏莹
 * 设计时间:5月30日
 * ***********************************/
namespace Business
{
    /// <summary>
    /// 菜肴种类操作的类
    /// </summary>
    public class BItemType
    {
        ItemTypeDal<ItemType> itemTypeOp = new ImpItemType();

        /// <summary>
        /// 增加一个菜肴种类
        /// </summary>
        /// <param name="itemtype">菜肴种类对象</param>
        /// <returns>1表示增加成功,0增加失败</returns>
        public int AddItemType(ItemType itemtype)
        {
            try
            {
                return itemTypeOp.AddItemType(itemtype);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        /// <summary>
        /// 修改一个菜肴种类
        /// </summary>
        /// <param name="itemtype">菜肴种类对象</param>
        /// <returns>1表示修改成功,0修改失败</returns>
        public int ModifyItemType(ItemType itemtype)
        {
            try
            {
                return itemTypeOp.EditItemType(itemtype);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        /// <summary>
        /// 删除一个种类
        /// </summary>
        /// <param name="itemtype">菜肴种类对象</param>
        /// <returns>1表示删除成功,0删除失败</returns>
        public int DeleteItemType(ItemType itemtype)
        {
            try
            {
                return itemTypeOp.DelteItemType(itemtype);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        /// <summary>
        /// 返回菜肴种类列表
        /// </summary>
        /// <returns>菜肴种类集合</returns>
        public IList<ItemType> GetItemTypes()
        {
            try
            {
                return itemTypeOp.ItemTypes();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }
}
