示例#1
0
        /// <summary>
        /// 添加穿搭
        /// </summary>
        /// <param name="suitPic">穿搭图片</param>
        /// <param name="name">穿搭名称</param>
        /// <param name="wardobeID">穿搭所属衣橱ID</param>
        /// <param name="clothesIDs">穿搭包含衣物ID列表</param>
        /// <returns>操作结果 是否成功添加</returns>
        public static bool add(IFormFile suitPic, string name, int wardobeID, int[] clothesIDs)
        {
            Suit suit = new Suit(name, wardobeID, ClothesManager.calculateWarmthDegree(clothesIDs).Value);

            suit.id = suitDb.InsertReturnIdentity(suit);

            List <Clothes_Suit> list = new List <Clothes_Suit>();

            foreach (int clothesID in clothesIDs)
            {
                list.Add(new Clothes_Suit(clothesID, suit.id));
            }

            if (suitPic != null)
            {
                savePic(suitPic, suit);
            }

            //插入数据库并返回操作结果
            return(clothes_suitDb.InsertRange(list.ToArray()));
        }
示例#2
0
        /// <summary>
        /// 依据有修改的衣物编号重新生成相关穿搭的适宜温度
        /// </summary>
        /// <param name="clothesID">有变更的衣物ID</param>
        public static void regenerateWarmthDegreeByClothes(int clothesID)
        {
            //找到衣物相关的所有穿搭
            foreach (int suitID in clothes_suitDb.GetList(x => x.clothesID == clothesID).Select(x => x.suitID))
            {
                Suit suit = suitDb.GetById(suitID);

                //确保穿搭存在
                if (suit != null)
                {
                    suit.warmthDegree = ClothesManager.calculateWarmthDegree(getClothes(suitID).clothes.Select(x => x.id).ToArray()).Value;
                    suitDb.Update(suit);
                }
#if DEBUG
                else
                {
                    throw new Exception();
                }
#endif
            }
        }
示例#3
0
        /// <summary>
        /// 对一套混搭的保暖程度进行评价
        /// </summary>
        /// <param name="clothes">混搭中的所有衣物</param>
        /// <param name="temperature">当前温度</param>
        /// <returns>评价结果</returns>
        public static EvaluationResponse evaluate(int[] clothes, double temperature)
        {
            KeyValuePair <bool, double> ans = ClothesManager.calculateWarmthDegree(clothes);

            return(new EvaluationResponse(ans.Key, evaluate(ans.Value, temperature)));
        }