예제 #1
0
 public WcfModel GetTagList()
 {
     try {
         TagService tagService = new TagService();
         var tag = tagService.GetTagList();
         var data = from o in tag
                    select new {
                        ID = o.ID.ToString(),
                        TagName = o.TagName,
                        NeedMoney = o.NeedMoney
                    };
         model.Data = JsonConvert.SerializeObject(data);
         model.Code = WcfStatus.QuerySuccessful;
     }
     catch {
         model.Code = WcfStatus.QueryError;
         model.ErrorMsg = "WTF";
     }
     return model;
 }
예제 #2
0
 public void UpdateUserTag(ObjectId id, ObjectId tagId)
 {
     var user = this.GetUserByID(id).First();
     var tag = new TagService().GetTagByID(tagId).First();
     int nowMoney = (user.Money ?? 0) - (tag.NeedMoney ?? 0);
     if (nowMoney < 0) {
         //现金少于0的异常
     }
     var query = Query<User>.EQ(o => o.ID, id);
     var update = Update.Set("Money", nowMoney).Push("Tags", tag.ID.ToString());
     userConn.Update(query, update);
 }