public virtual Result Buy( int buyerId, int creatorId, ForumTopic topic ) { if (topic == null) throw new ArgumentNullException( "ForumBuyLogService.Buy" ); Result result = new Result(); if (topic.Price <= 0) { result.Add( "topic.price <=0" ); return result; } if (incomeService.HasEnoughKeyIncome( buyerId, topic.Price ) == false) { result.Add( String.Format( alang.get( typeof( ForumApp ), "exIncome" ), KeyCurrency.Instance.Name ) ); return result; } // 购买日志 ForumBuyLog log = new ForumBuyLog(); log.UserId = buyerId; log.TopicId = topic.Id; log.insert(); String msg = string.Format( "访问需要购买的帖子 <a href=\"{0}\">{1}</a>", alink.ToAppData( topic ), topic.Title ); incomeService.AddKeyIncome( buyerId, -topic.Price, msg ); String msg2 = string.Format( "销售帖子 <a href=\"{0}\">{1}</a>", alink.ToAppData( topic ), topic.Title ); incomeService.AddKeyIncome( creatorId, topic.Price, msg2 ); return result; }
public virtual Result Buy(long buyerId, long creatorId, ForumTopic topic) { if (topic == null) { throw new ArgumentNullException("ForumBuyLogService.Buy"); } Result result = new Result(); if (topic.Price <= 0) { result.Add("topic.price <=0"); return(result); } if (incomeService.HasEnoughKeyIncome(buyerId, topic.Price) == false) { result.Add(String.Format(alang.get(typeof(ForumApp), "exIncome"), KeyCurrency.Instance.Name)); return(result); } // 购买日志 ForumBuyLog log = new ForumBuyLog(); log.UserId = buyerId; log.TopicId = topic.Id; log.insert(); String msg = string.Format("访问需要购买的帖子 <a href=\"{0}\">{1}</a>", alink.ToAppData(topic), topic.Title); incomeService.AddKeyIncome(buyerId, -topic.Price, msg); String msg2 = string.Format("销售帖子 <a href=\"{0}\">{1}</a>", alink.ToAppData(topic), topic.Title); incomeService.AddKeyIncome(creatorId, topic.Price, msg2); return(result); }