Пример #1
0
 /// <summary>
 /// 创建套餐对象
 /// </summary>
 /// <param name="name">套餐名</param>
 public void CreatePackage(string name)
 {
     if (HealthPackages.Any(x => x.Name == name))
     {
         throw new Exception("该套餐已存在,请勿重复添加!");
     }
     HealthPackages.Add(new HealthPackage()
     {
         Id   = HealthPackages.Count + 1,
         Name = name
     });
 }
Пример #2
0
        /// <summary>
        /// 向套餐中添加检查项
        /// </summary>
        /// <param name="packageId">套餐ID</param>
        /// <param name="itemId">检查项ID</param>
        public void CreateItemByPackage(int packageId, int itemId)
        {
            var package = HealthPackages.First(x => x.Id == packageId);

            if (package.HealthItems.Any(x => x.Id == itemId))
            {
                throw new Exception($"该项目已经存在套餐{package.Name}中,请勿重复添加!");
            }
            var item = HealthItems.First(x => x.Id == itemId);

            package.HealthItems.Add(item);
        }
Пример #3
0
        /// <summary>
        /// 向套餐中移除检查项
        /// </summary>
        /// <param name="packageId">套餐ID</param>
        /// <param name="itemId">检查项ID</param>
        public void RemoveItemByPackage(int packageId, int itemId)
        {
            var package = HealthPackages.First(x => x.Id == packageId);

            if (!package.HealthItems.Any(x => x.Id == itemId))
            {
                throw new Exception($"该项目不存在套餐{package.Name}中,请重新选择!");
            }
            var item = HealthItems.First(x => x.Id == itemId);

            package.HealthItems.Remove(item);
        }