private async Task CreateUpdateTenant(PaymentPeriodType paymentPeriodType, EditionPaymentType editionPaymentType, DateTime?subscriptionEndDate, DateTime updatedSubscriptionEndDate) { await _editionManager.CreateAsync(new SubscribableEdition { Name = "CurrentEdition", DisplayName = "Current Edition" }); await _editionManager.CreateAsync(new SubscribableEdition { Name = "TargetEdition", DisplayName = "Target Edition" }); var currentEditionId = (await _editionManager.FindByNameAsync("CurrentEdition")).Id; var targetEditionId = (await _editionManager.FindByNameAsync("TargetEdition")).Id; // Create tenant await _tenantAppService.CreateTenant( new CreateTenantInput { TenancyName = "testTenant", Name = "Tenant for test purpose", AdminEmailAddress = "*****@*****.**", AdminPassword = "******", IsActive = true, EditionId = currentEditionId, SubscriptionEndDateUtc = subscriptionEndDate }); //Assert var tenant = await GetTenantOrNullAsync("testTenant"); tenant.ShouldNotBe(null); tenant.Name.ShouldBe("Tenant for test purpose"); tenant.IsActive.ShouldBe(true); tenant.EditionId.ShouldBe(currentEditionId); tenant.SubscriptionEndDateUtc = subscriptionEndDate?.ToUniversalTime(); // Update Tenant ----------------------------- var tenantForUpdate = _tenantManager.UpdateTenantAsync( tenant.Id, true, false, paymentPeriodType, targetEditionId, editionPaymentType ); //Assert tenant = await tenantForUpdate; tenant.IsActive.ShouldBe(true); tenant.IsInTrialPeriod.ShouldBe(false); tenant.EditionId.ShouldBe(targetEditionId); tenant.SubscriptionEndDateUtc.ShouldNotBe(null); tenant.SubscriptionEndDateUtc?.Date.ShouldBe(updatedSubscriptionEndDate.ToUniversalTime().Date); }
public async Task CreateEdition(NewEditionInput input) { if (input.Id == 0) { var newEdition = new CinotamEdition { DisplayName = input.DisplayName, Price = input.Price }; await _editionManager.CreateAsync(newEdition); await CurrentUnitOfWork.SaveChangesAsync(); await SetFeatureValues(newEdition, input.Features); await _editionNotificationsSender.SendNotificationEditionCreated(newEdition, await GetCurrentUserAsync()); } else { var edition = await _editionManager.GetByIdAsync(input.Id); var mapped = input.MapTo(edition); await _editionRepository.UpdateAsync(mapped); await SetFeatureValues(mapped, input.Features); await _editionNotificationsSender.SendNotificationEditionEdited(edition, await GetCurrentUserAsync()); } }
public async Task Should_Create_Edition() { await _editionManager.CreateAsync(new Edition { Name = "Standard", DisplayName = "Standard Edition" }); UsingDbContext(context => { context.Editions.FirstOrDefault(e => e.Name == "Standard").ShouldNotBeNull(); }); }
protected virtual async Task CreateEditionAsync(CreateOrUpdateEditionDto input) { var edition = new Edition(input.Edition.DisplayName); await _editionManager.CreateAsync(edition); await CurrentUnitOfWork.SaveChangesAsync(); //It's done to get Id of the edition. await SetFeatureValues(edition, input.FeatureValues); }
protected virtual async Task CreateEditionAsync(CreateOrUpdateEditionDto input) { var edition = ObjectMapper.Map <SubscribableEdition>(input.Edition); if (edition.ExpiringEditionId.HasValue) { var expiringEdition = (SubscribableEdition)await _editionManager.GetByIdAsync(edition.ExpiringEditionId.Value); if (!expiringEdition.IsFree) { throw new UserFriendlyException(L("ExpiringEditionMustBeAFreeEdition")); } } await _editionManager.CreateAsync(edition); await CurrentUnitOfWork.SaveChangesAsync(); //It's done to get Id of the edition. await SetFeatureValues(edition, input.FeatureValues); }