private void CreateContact(Guid employerId, Guid memberId) { var exercisedCredit = new ExercisedCredit { ExercisedById = employerId, ExercisedOnId = memberId, }; exercisedCredit.Prepare(); _creditsRepository.CreateExercisedCredit(exercisedCredit); }
private void Use(Allocation allocation, int quantity, DateTime date) { for (var index = 0; index < quantity; ++index) { _creditsRepository.CreateExercisedCredit(new ExercisedCredit { Id = Guid.NewGuid(), AdjustedAllocation = true, AllocationId = allocation.Id, CreditId = allocation.CreditId, ExercisedById = allocation.OwnerId, ExercisedOnId = Guid.NewGuid(), Time = date.AddMinutes(index), }); allocation.RemainingQuantity = allocation.RemainingQuantity.Value - 1; } _creditsRepository.UpdateAllocation(allocation); }
private void ExerciseCredit(int?quantity, HierarchyPath hierarchyPath, Guid ownerId, Guid?allocationId, Guid exercisedById, Guid exercisedOnId) { // Allocate credits to owner. var credit = _creditsQuery.GetCredit <ContactCredit>(); if (allocationId != null) { // Exercise a credit using an allocation. var allocation = new Allocation { Id = allocationId.Value, OwnerId = ownerId, CreditId = credit.Id, InitialQuantity = quantity }; _allocationsCommand.CreateAllocation(allocation); // Exercise a credit. var exercisedCreditId = _exercisedCreditsCommand.ExerciseCredit(credit.Id, hierarchyPath, true, exercisedById, exercisedOnId, null); Assert.AreEqual(allocation.Id, _exercisedCreditsQuery.GetExercisedCredit(exercisedCreditId.Value).AllocationId); } else { // To test the support for old candidate access before allocations were introduced directly update the database. // A record is kept that the owner has contacted the candidate but that no allocation is used. var exercise = new ExercisedCredit { Id = Guid.NewGuid(), Time = DateTime.Now, CreditId = credit.Id, ExercisedById = exercisedById, ExercisedOnId = exercisedOnId, AllocationId = null, ReferenceId = null, }; _repository.CreateExercisedCredit(exercise); } }