Esempio n. 1
0
        public void Should_Convert_To_Entity()
        {
            var measureCommandDto = Domain.Dtos.Measure.MeasureCommandDto.New("teste", StatusEnum.Enable, Guid.NewGuid());
            var entity            = MeasureMapper.Map(measureCommandDto);

            Assert.NotNull(entity);
        }
Esempio n. 2
0
        public void Should_Convert_To_Dto()
        {
            var measure = Domain.Entities.Measure.New("test", StatusEnum.Enable, TenantId.New());
            var dto     = MeasureMapper.Map(measure);

            Assert.NotNull(dto);
        }
Esempio n. 3
0
        public async Task <Unit> Handle(InsertMeasureCommandRequest request, CancellationToken cancellationToken)
        {
            var measure = MeasureMapper.Map(request.MeasureInsertDto);

            await _measureRepository.InsertAsync(measure);

            return(Unit.Value);
        }
Esempio n. 4
0
        public void Should_Convert_To_List_Of_Dto2()
        {
            var measures = new Domain.Entities.Measure[] { };
            var dtos     = MeasureMapper.Map(measures).ToList();

            Assert.Empty(dtos);
            Assert.NotNull(dtos);
        }
Esempio n. 5
0
        public async Task <MeasureQueryDto> Handle(GetMeasureQueryRequest request, CancellationToken cancellationToken)
        {
            var measure = await _measureRepository.GetAsync(request.MeasureId);

            var measureDto = MeasureMapper.Map(measure);

            return(measureDto);
        }
Esempio n. 6
0
        public void Should_Convert_To_List_Of_Dto()
        {
            var measures = new Domain.Entities.Measure[]
            {
                Domain.Entities.Measure.New("test 1", StatusEnum.Enable, TenantId.New()),
                Domain.Entities.Measure.New("test 2", StatusEnum.Enable, TenantId.New())
            };
            var dtos = MeasureMapper.Map(measures).ToList();

            Assert.NotEmpty(dtos);
            Assert.NotNull(dtos);
        }
Esempio n. 7
0
        public async Task <IPagination <MeasureQueryDto> > Handle(ListMeasureQueryRequest request, CancellationToken cancellationToken)
        {
            var pagination = await _measureRepository.ListAsync(request.Filter, request.OrderBy, request.Page, request.QtyPerPage);

            if (pagination.IsEmpty())
            {
                return(Pagination <MeasureQueryDto> .Empty);
            }

            var measureDtos = MeasureMapper.Map(pagination.Entities);

            var paginationDto = Pagination <MeasureQueryDto> .New(measureDtos, pagination.TotalPages, pagination.ItemsPerPage, pagination.CurrentPage);

            return(paginationDto);
        }
Esempio n. 8
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            CommentMapper.Map(modelBuilder.Entity <Comment>());
            IngredientMapper.Map(modelBuilder.Entity <Ingredient>());
            LikeMapper.Map(modelBuilder.Entity <Like>());
            MeasureMapper.Map(modelBuilder.Entity <Measure>());
            RecipeTagMapper.Map(modelBuilder.Entity <RecipeTag>());
            TagMapper.Map(modelBuilder.Entity <Tag>());
            RecipeMapper.Map(modelBuilder.Entity <Recipe>());
            UserMapper.Map(modelBuilder.Entity <User>());

            foreach (var relationship in modelBuilder.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys()))
            {
                relationship.DeleteBehavior = DeleteBehavior.Restrict;
            }
        }