Beispiel #1
0
        public async Task <PartialViewResult> CreateModal(int?id)
        {
            var output = await _editionAppService.GetEditionForEdit(new NullableIdDto { Id = id });

            var viewModel = ObjectMapper.Map <CreateEditionModalViewModel>(output);

            viewModel.EditionItems     = await _editionAppService.GetEditionComboboxItems();;
            viewModel.FreeEditionItems = await _editionAppService.GetEditionComboboxItems(output.Edition.ExpiringEditionId, false, true);;

            return(PartialView("_CreateModal", viewModel));
        }
Beispiel #2
0
        public async Task <PartialViewResult> CreateOrEditModal(int?id)
        {
            var output = await _editionAppService.GetEditionForEdit(new NullableIdDto { Id = id });

            var viewModel = new CreateOrEditEditionModalViewModel(output);

            return(PartialView("_CreateOrEditModal", viewModel));
        }
        public async Task <PartialViewResult> CreateOrEditModal(int?id)
        {
            IEditionAppService editionAppService = this._editionAppService;
            NullableIdInput    nullableIdInput   = new NullableIdInput()
            {
                Id = id
            };
            GetEditionForEditOutput editionForEdit = await editionAppService.GetEditionForEdit(nullableIdInput);

            return(this.PartialView("_CreateOrEditModal", new CreateOrEditEditionModalViewModel(editionForEdit)));
        }
        public async Task <PartialViewResult> CreateOrEditModal(int?id)
        {
            var output = await _editionAppService.GetEditionForEdit(new NullableIdDto { Id = id });

            var editionItems = await _editionAppService.GetEditionComboboxItems();

            var freeEditionItems = await _editionAppService.GetEditionComboboxItems(output.Edition.ExpiringEditionId, false, true);

            var viewModel = new CreateOrEditEditionModalViewModel(output, editionItems, freeEditionItems);

            return(PartialView("_CreateOrEditModal", viewModel));
        }
        public async Task Should_Create_Edition()
        {
            //Getting edition for edit
            var output = await _editionAppService.GetEditionForEdit(new NullableIdDto(null));

            //Changing a sample feature value
            var chatFeature = output.FeatureValues.FirstOrDefault(f => f.Name == AppFeatures.ChatFeature);

            if (chatFeature != null)
            {
                chatFeature.Value = chatFeature.Value = "true";
            }

            await _editionAppService.CreateOrUpdateEdition(
                new CreateOrUpdateEditionDto
            {
                Edition = new EditionEditDto
                {
                    DisplayName = "Premium Edition"
                },
                FeatureValues = output.FeatureValues
            });

            await UsingDbContextAsync(async context =>
            {
                var premiumEditon = await context.Editions.FirstOrDefaultAsync(e => e.DisplayName == "Premium Edition");
                premiumEditon.ShouldNotBeNull();

                if (chatFeature != null)
                {
                    var sampleFeatureValue = context.EditionFeatureSettings.FirstOrDefault(s => s.EditionId == premiumEditon.Id && s.Name == AppFeatures.ChatFeature);
                    sampleFeatureValue.ShouldNotBe(null);
                    sampleFeatureValue.Value.ShouldBe("true");
                }
            });
        }
Beispiel #6
0
        public async Task Should_Not_Create_User_More_Than_Allowed_Count()
        {
            //Getting edition for edit
            var output = await _editionAppService.GetEditionForEdit(new NullableIdDto(null));

            //Changing a sample feature value
            var maxUserCountFeature = output.FeatureValues.FirstOrDefault(f => f.Name == AppFeatures.MaxUserCount);

            if (maxUserCountFeature != null)
            {
                maxUserCountFeature.Value = "2";
            }

            await _editionAppService.CreateEdition(
                new CreateEditionDto
            {
                Edition = new EditionCreateDto
                {
                    DisplayName = "Premium Edition"
                },
                FeatureValues = output.FeatureValues
            });


            var premiumEditon = (await _editionAppService.GetEditions()).Items.FirstOrDefault(e => e.DisplayName == "Premium Edition");

            premiumEditon.ShouldNotBeNull();

            await UsingDbContextAsync(async context =>
            {
                var tenant       = await context.Tenants.SingleAsync(t => t.TenancyName == AbpTenantBase.DefaultTenantName);
                tenant.EditionId = premiumEditon.Id;

                context.SaveChanges();
            });

            LoginAsDefaultTenantAdmin();

            // This is second user (first is tenant admin)
            await _userAppService.CreateOrUpdateUser(
                new CreateOrUpdateUserInput
            {
                User = new UserEditDto
                {
                    EmailAddress = "*****@*****.**",
                    Name         = "John",
                    Surname      = "Nash",
                    UserName     = "******",
                    Password     = "******"
                },
                AssignedRoleNames = new string[] { }
            });

            //Act
            var exception = await Assert.ThrowsAsync <UserFriendlyException>(
                async() =>
                await _userAppService.CreateOrUpdateUser(
                    new CreateOrUpdateUserInput
            {
                User = new UserEditDto
                {
                    EmailAddress = "*****@*****.**",
                    Name         = "Ali Rıza",
                    Surname      = "Adıyahşi",
                    UserName     = "******",
                    Password     = "******"
                },
                AssignedRoleNames = new string[] { }
            })
                );

            exception.Message.ShouldContain(_localizationManager.GetString(ERPConsts.LocalizationSourceName, "MaximumUserCount_Error_Message"));
        }