public void AddRewardPointsHistoryEntry(int points, string message = "", Order usedWithOrder = null, decimal usedAmount = 0M) { int newPointsBalance = this.GetRewardPointsBalance() + points; var rewardPointsHistory = new RewardPointsHistory() { Customer = this, UsedWithOrder = usedWithOrder, Points = points, PointsBalance = newPointsBalance, UsedAmount = usedAmount, Message = message, CreatedOnUtc = DateTime.UtcNow }; this.RewardPointsHistory.Add(rewardPointsHistory); }
public void Can_save_and_load_rewardPointsHistory_with_order() { var rewardPointsHistory = new RewardPointsHistory() { Customer = GetTestCustomer(), UsedWithOrder = GetTestOrder(), Points = 1, Message = "Points for registration", PointsBalance = 2, UsedAmount = 3, CreatedOnUtc = new DateTime(2010, 01, 01) }; var fromDb = SaveAndLoadEntity(rewardPointsHistory); fromDb.ShouldNotBeNull(); fromDb.UsedWithOrder.ShouldNotBeNull(); fromDb.UsedWithOrder.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01)); }