public async Task <BaseResponse> GetEntity([FromBody] GetEntityRequest request)
 => await RequestHelpers.GetEntity
 (
     request,
     repository,
     mapper
 );
Ejemplo n.º 2
0
        public void Get_Residency_ById_And_Courses_WithoutGenericHelper()
        {
            //arrange
            var filterLambdaOperatorDescriptor = GetFilterExpressionDescriptor <ResidencyModel>
                                                 (
                GetResidencyByIdFilterBody(2),
                "q"
                                                 );

            IMapper mapper = serviceProvider.GetRequiredService <IMapper>();
            IEnrollmentRepository repository = serviceProvider.GetRequiredService <IEnrollmentRepository>();

            //act
            var expression      = mapper.MapToOperator(filterLambdaOperatorDescriptor).Build();
            var selectAndExpand = new Common.Configuration.ExpansionDescriptors.SelectExpandDefinitionDescriptor
            {
                ExpandedItems = new List <Common.Configuration.ExpansionDescriptors.SelectExpandItemDescriptor>
                {
                    new Common.Configuration.ExpansionDescriptors.SelectExpandItemDescriptor
                    {
                        MemberName = "StatesLivedIn"
                    }
                }
            };

            var entity = (ResidencyModel)RequestHelpers.GetEntity
                         (
                new Business.Requests.GetEntityRequest
            {
                Filter = filterLambdaOperatorDescriptor,
                SelectExpandDefinition = selectAndExpand,
                ModelType = typeof(ResidencyModel).AssemblyQualifiedName,
                DataType  = typeof(Residency).AssemblyQualifiedName
            },
                repository,
                mapper
                         ).Result.Entity;

            //assert
            AssertFilterStringIsCorrect(expression, "q => (q.UserId == 2)");
            Assert.Equal(2, entity.StatesLivedIn.Count);
        }