public static DrinkEntity ToEntity(this DrinkDto dto) { var entity = new DrinkEntity { Id = dto.Id, Name = dto.Name, Price = dto.Price, DrinkIngredients = dto.DrinkIngredients != null?dto.DrinkIngredients.Select(di => di.ToEntity()).ToList() : new List <DrinkIngredient>() }; return(entity); }
public static DrinkDto ToDto(this DrinkEntity entity) { var dto = new DrinkDto { Id = entity.Id, Name = entity.Name, Price = entity.Price, DrinkIngredients = entity.DrinkIngredients.Select(di => di.ToDto()).ToList() }; return(dto); }