Пример #1
0
        /// <summary>
        /// 保存用户积分
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="lllegallevel"></param>
        public void SaveUserScore(string userid, string lllegallevel)
        {
            // 一般违章 、较严重违章、严重违章
            var     item      = new DataItemDetailBLL().GetDataItemListByItemCode(" 'LllegalRegister'").ToList();
            var     scoreitem = scoresetbll.GetList("").ToList(); //查询标准
            string  personID  = userid;
            string  itemID    = string.Empty;
            decimal score     = 0;

            //违章级别ID
            if (!string.IsNullOrEmpty(lllegallevel))
            {
                var detail = new DataItemDetailBLL().GetEntity(lllegallevel);

                if (null != detail)
                {
                    if (item.Count() > 0)
                    {
                        string[] levelids = item.FirstOrDefault().ItemValue.ToString().Split('|');
                        //一般违章
                        if (detail.ItemName == "一般违章")
                        {
                            itemID = levelids[0].ToString();
                        }
                        //较严重违章
                        else if (detail.ItemName == "较严重违章")
                        {
                            itemID = levelids[1].ToString();
                        }
                        else  //严重违章
                        {
                            itemID = levelids[2].ToString();
                        }
                        if (!string.IsNullOrEmpty(itemID))
                        {
                            var tempItem = scoreitem.Where(p => p.Id == itemID).FirstOrDefault();
                            if (null != tempItem)
                            {
                                score = tempItem.ItemType == "加分" ? tempItem.Score.Value : -tempItem.Score.Value;
                            }
                        }
                    }
                }


                if (!string.IsNullOrEmpty(personID))
                {
                    UserScoreEntity us = new UserScoreEntity
                    {
                        UserId = personID,
                        ItemId = itemID,
                        Score  = score
                    };
                    new UserScoreBLL().SaveForm("", us);
                }
            }
        }