Example #1
0
        public void PrefilterViewModel(VmOrganizationStep1 vm)
        {
            if (vm.Id != null && vm.Id == vm.ParentId)
            {
                throw new PtvArgumentException("Organization can not be simultaneously parent itself.");
            }

            webPageLogic.PrefilterModel(vm);
            addressLogic.PrefilterModel(vm);
        }
Example #2
0
        private void CheckTranslation(VmOrganizationModel source, VmOrganizationStep1 step1, OrganizationVersioned target)
        {
            target.Id.Should().NotBe(Guid.Empty);

            var names = conversion.GetValidTextsSkipEmpty(step1.OrganizationName, step1.OrganizationAlternateName);

            target.OrganizationNames.Count.Should().Be(Math.Max(names.Count, 1), "OrganizationNames");

            var descriptions = conversion.GetValidTexts(step1.Description);

            target.OrganizationDescriptions.Count.Should().Be(descriptions.Count, "OrganizationDescriptions");

            if (step1.ParentId.HasValue)
            {
                target.ParentId.Should().NotBeEmpty();
                target.ParentId.Should().Be(step1.ParentId.Value);
            }

            if (step1.Municipality?.Id != null)
            {
                target.MunicipalityId.Should().NotBeEmpty();
                target.MunicipalityId.Should().Be(step1.Municipality?.Id);
            }

            if (step1.OrganizationTypeId.HasValue)
            {
                target.TypeId.Should().NotBeEmpty();
                target.TypeId.Should().Be(step1.OrganizationTypeId.Value);
            }

            if (step1.ShowContacts)
            {
                target.OrganizationEmails.Count.Should().Be(step1.Emails.Count, "Emails");
                target.OrganizationPhones.Count.Should().Be(step1.PhoneNumbers.Count, "Phone");
                target.OrganizationWebAddress.Count.Should().Be(step1.WebPages.Count, "Web pages");

                if (step1.ShowPostalAddress || step1.ShowVisitingAddress)
                {
                    target.OrganizationAddresses.Count.Should().Be(step1.PostalAddresses.Count + step1.VisitingAddresses.Count, "Adresses");
                }
            }
        }