void IAllocationsCommand.CreateAllocation(Allocation allocation) { // Make sure the expiry date is in fact a date. if (allocation.ExpiryDate != null) { allocation.ExpiryDate = allocation.ExpiryDate.Value.Date; } Prepare(allocation); _repository.CreateAllocation(allocation); }
private Allocation Allocate(Guid ownerId, int?quantity, DateTime date) { var creditId = _creditsQuery.GetCredit <ContactCredit>().Id; var allocation = new Allocation { Id = Guid.NewGuid(), OwnerId = ownerId, CreditId = creditId, CreatedTime = date, InitialQuantity = quantity, RemainingQuantity = quantity }; allocation.ExpiryDate = allocation.CreatedTime.AddYears(1); _creditsRepository.CreateAllocation(allocation); return(allocation); }