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); }
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); }
public async Task <Unit> Handle(InsertMeasureCommandRequest request, CancellationToken cancellationToken) { var measure = MeasureMapper.Map(request.MeasureInsertDto); await _measureRepository.InsertAsync(measure); return(Unit.Value); }
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); }
public async Task <MeasureQueryDto> Handle(GetMeasureQueryRequest request, CancellationToken cancellationToken) { var measure = await _measureRepository.GetAsync(request.MeasureId); var measureDto = MeasureMapper.Map(measure); return(measureDto); }
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); }
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); }
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; } }