public void ProcessManualEvent(string feedMessage, User user, int pointValue) { var timeStamp = DateTime.UtcNow; var eventDefinition = new EventDefinition { EventDefinitionID = "Manual", PointValue = pointValue }; var ledgerEntry = new PointLedgerEntry { UserID = user.UserID, EventDefinitionID = eventDefinition.EventDefinitionID, Points = eventDefinition.PointValue, TimeStamp = timeStamp }; _pointLedgerRepository.RecordEntry(ledgerEntry); _profileService.UpdatePointTotal(user); _feedService.PublishToFeed(user, feedMessage, eventDefinition.PointValue, timeStamp); }
public virtual void RecordEntry(PointLedgerEntry entry) { _sqlObjectFactory.GetConnection().Using(connection => connection.Command("INSERT INTO pf_PointLedger (UserID, EventDefinitionID, Points, TimeStamp) VALUES (@UserID, @EventDefinitionID, @Points, @TimeStamp)") .AddParameter("@UserID", entry.UserID) .AddParameter("@EventDefinitionID", entry.EventDefinitionID) .AddParameter("@Points", entry.Points) .AddParameter("@TimeStamp", entry.TimeStamp) .ExecuteNonQuery()); }
public void ProcessEventPublishesToLedger() { var user = new User(123, DateTime.MinValue); var eventDef = new EventDefinition {EventDefinitionID = "blah", PointValue = 42}; const string message = "msg"; var publisher = GetPublisher(); _eventDefService.Setup(x => x.GetEventDefinition(eventDef.EventDefinitionID)).Returns(eventDef); var entry = new PointLedgerEntry(); _pointLedgerRepo.Setup(x => x.RecordEntry(It.IsAny<PointLedgerEntry>())).Callback<PointLedgerEntry>(x => entry = x); publisher.ProcessEvent(message, user, eventDef.EventDefinitionID, false); Assert.AreEqual(user.UserID, entry.UserID); Assert.AreEqual(eventDef.EventDefinitionID, entry.EventDefinitionID); Assert.AreEqual(eventDef.PointValue, entry.Points); }
public void ProcessEvent(string feedMessage, User user, string eventDefinitionID, bool overridePublishToActivityFeed) { var timeStamp = DateTime.UtcNow; var eventDefinition = _eventDefinitionService.GetEventDefinition(eventDefinitionID); var ledgerEntry = new PointLedgerEntry { UserID = user.UserID, EventDefinitionID = eventDefinitionID, Points = eventDefinition.PointValue, TimeStamp = timeStamp }; _pointLedgerRepository.RecordEntry(ledgerEntry); _profileService.UpdatePointTotal(user); if (eventDefinition.IsPublishedToFeed && !overridePublishToActivityFeed) { _feedService.PublishToFeed(user, feedMessage, eventDefinition.PointValue, timeStamp); _feedService.PublishToActivityFeed(feedMessage); } _awardCalculator.QueueCalculation(user, eventDefinition); }
public void ProcessManualEventPublishesToLedger() { var user = new User(123, DateTime.MinValue); const string message = "msg"; const int points = 252; var publisher = GetPublisher(); var entry = new PointLedgerEntry(); _pointLedgerRepo.Setup(x => x.RecordEntry(It.IsAny<PointLedgerEntry>())).Callback<PointLedgerEntry>(x => entry = x); publisher.ProcessManualEvent(message, user, points); Assert.AreEqual(user.UserID, entry.UserID); Assert.AreEqual("Manual", entry.EventDefinitionID); Assert.AreEqual(points, entry.Points); }