当前位置: 首页>>代码示例>>C#>>正文


C# Core.ToDomainEnumeration方法代码示例

本文整理汇总了C#中Core.ToDomainEnumeration方法的典型用法代码示例。如果您正苦于以下问题:C# Core.ToDomainEnumeration方法的具体用法?C# Core.ToDomainEnumeration怎么用?C# Core.ToDomainEnumeration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Core的用法示例。


在下文中一共展示了Core.ToDomainEnumeration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OrganisationUser

            GetOrganisationBySimpleSearchTerm_SearchIsValid_AndNoConflictingOrganisationUserExists_ReturnsOrganisation(
            string existingUserId, string userId, Core.Shared.UserStatus userStatus, Core.Shared.OrganisationStatus organisationStatus)
        {
            var organisation = A.Fake<Organisation>();
            A.CallTo(() => organisation.TradingName).Returns("A Company");
            A.CallTo(() => organisation.OrganisationStatus).Returns(organisationStatus.ToDomainEnumeration<OrganisationStatus>());

            A.CallTo(() => context.Organisations)
                .Returns(dbContextHelper.GetAsyncEnabledDbSet(new List<Organisation> { organisation }));

            var organisationUser = new OrganisationUser(new Guid(userId), new Guid(existingUserId), userStatus.ToDomainEnumeration<UserStatus>());
            A.CallTo(() => context.OrganisationUsers)
                .Returns(dbContextHelper.GetAsyncEnabledDbSet(new List<OrganisationUser>
                {
                    organisationUser
                }));

            var result = await FindMatchingOrganisationsDataAccess().GetOrganisationsBySimpleSearchTerm("A", new Guid(userId));

            Assert.Single(result);
            Assert.Equal(organisation, result.Single());
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:22,代码来源:FindMatchingOrganisationsDataAccessTests.cs

示例2: ChangeOrganisationUserStatus

 public async Task<int> ChangeOrganisationUserStatus(OrganisationUser organisationUser, Core.Shared.UserStatus status)
 {
     organisationUser.UpdateUserStatus(status.ToDomainEnumeration<UserStatus>());
     return await context.SaveChangesAsync();
 }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:5,代码来源:UpdateOrganisationUserStatusDataAccess.cs

示例3: ValidOrganisationUser

 private OrganisationUser ValidOrganisationUser(Guid userId, Guid organisationId, Core.Shared.UserStatus userStatus)
 {
     return new OrganisationUser(userId, organisationId, userStatus.ToDomainEnumeration<UserStatus>());
 }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:4,代码来源:JoinOrganisationDataAccessTests.cs

示例4: using

        public async void GetOrganisationUsers_SameUserRejectedMultipleTimesForOneOrganisation_ButAlsoHasAnotherStatus_ReturnsTheOtherStatus(Core.Shared.UserStatus status)
        {
            using (var dbWrapper = new DatabaseWrapper())
            {
                // Add AspNet user user
                var modelHelper = new ModelHelper(dbWrapper.Model);
                var aspNetUser = modelHelper.CreateUser("My username", IdType.Guid);
                dbWrapper.Model.SaveChanges();

                // Add organisation
                var uniqueOrgName = "Test Org " + Guid.NewGuid();
                var country = dbWrapper.WeeeContext.Countries.First();
                var organisation = Domain.Organisation.Organisation.CreateSoleTrader(uniqueOrgName);
                organisation.AddOrUpdateMainContactPerson(new Domain.Organisation.Contact("First name", "Last name", "Developer"));
                organisation.AddOrUpdateAddress(AddressType.OrganisationAddress, new Domain.Organisation.Address(
                    "Address line 1",
                    string.Empty,
                    "Town",
                    string.Empty,
                    string.Empty,
                    country,
                    "01234567890",
                    "[email protected]"));
                organisation.CompleteRegistration();
                dbWrapper.WeeeContext.Organisations.Add(organisation);
                dbWrapper.WeeeContext.SaveChanges();

                // Add same organisation user multiple times, rejected
                var rejectedOrganisationUsers = new List<Domain.Organisation.OrganisationUser>
                {
                    new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
                        organisation.Id,
                        UserStatus.Rejected),
                    new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
                        organisation.Id,
                        UserStatus.Rejected),
                    new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
                        organisation.Id,
                        UserStatus.Rejected)
                };

                var otherOrganisationUser = new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
                    organisation.Id,
                    status.ToDomainEnumeration<UserStatus>());

                dbWrapper.WeeeContext.OrganisationUsers.AddRange(rejectedOrganisationUsers);
                dbWrapper.WeeeContext.OrganisationUsers.Add(otherOrganisationUser);
                dbWrapper.WeeeContext.SaveChanges();

                var dataAccess = new FindMatchingUsersDataAccess(dbWrapper.WeeeContext);

                var result = (await dataAccess.GetOrganisationUsers())
                    .Where(ou => ou.OrganisationName == uniqueOrgName);

                Assert.Single(result);

                var organisationUser = result.Single();
                Assert.Equal(status, organisationUser.Status);
            }
        }
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:60,代码来源:FindMatchingUsersDataAccessTests.cs


注:本文中的Core.ToDomainEnumeration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。