public void UpDownDoubt(string doubtId, string userId, string operation) { using (var biz = new GameBiz.Business.GameBizBusinessManagement()) { biz.BeginTran(); using (var manager = new DoubtManager()) { var entity = manager.GetDoubtById(doubtId); if (entity == null) { throw new ArgumentException("指定编号的问题不存在"); } var record = manager.GetUpDownRecord(userId, doubtId); if (record != null) { throw new ArgumentException("不能重复操作"); } if (operation.ToUpper() == "UP") { entity.UpCount++; } else { entity.DownCount++; } manager.UpdateDoubt(entity); record = new UpDownRecord { UserId = userId, DoubtId = doubtId, UpDown = operation, CreateTime = DateTime.Now, }; manager.AddUpDownRecord(record); } biz.CommitTran(); } }
public void AddUpDownRecord(UpDownRecord record) { record.CreateTime = DateTime.Now; Add <UpDownRecord>(record); }